For members of the same class, you can use parentheses (regular array):
Vehicles(1) = Vehicle(100); Vehicles(2) = Vehicle(200); Vehicles(3) = Vehicle(50);
To set all objects, use deal :
[Vehicles(:).Is_Active] = deal( true );
You can also initialize an array of objects .
For your questions (2) and (3), the syntax is equivalent to the syntax of MATLAB structures:
speedArray = [Vehicles.Speed]; fasterThanX = Vehicles( speedArray > X );
This vectorization notation is a strong point of MATLAB and is widely used.
Mikhail
source share