Variable-sized arrays

3 次查看(过去 30 天)
Alexander Maier
Alexander Maier 2020-4-24
Hello,
how could I define variable sized data generation in my code?
I would like to extract actor data from "automated driving toolbox "- generated scenarios based on the numbers of different actors. The following code extracts the data, which is needed in my case, but has to be changed when it comes to different scenarios with varying actor amounts.
%
%% Vehicle1 EGO VEHICLE
Position2 = repmat(data.ActorSpecifications(1, 2).Position, p, 1);
Yaw2 = repmat(data.ActorSpecifications(1, 2).Yaw, p, 1);
Velocity2= repmat(data.ActorSpecifications(1, 2).Speed, p,1);
%Vehicle3
Position3 = repmat(data.ActorSpecifications(1, 3).Position, p, 1);
Yaw3 = repmat(data.ActorSpecifications(1, 3).Yaw, p, 1);
Velocity3= repmat(data.ActorSpecifications(1, 3).Speed, p,1);
%Vehicle4
Position4 = repmat(data.ActorSpecifications(1, 4).Position, p ,1);
Yaw4 = repmat(data.ActorSpecifications(1, 4).Yaw, p, 1) ;
Velocity4= repmat(data.ActorSpecifications(1, 4).Speed, p,1);
f1= 'Position'; v1= {Position2, Position3, Position4};
f2= 'Yaw'; v2= {Yaw2, Yaw3, Yaw4};
f3= 'Velocity'; v3= {Velocity2, Velocity3, Velocity4};
f4= 'SimulationTime'; v4= SimTime;
otherVehicles = struct(f1, v1, f2, v2, f3, v3, f4, v4);
I would like to eliminate the manual work for data generation. Any ideas, how this could be done?
Thank you in advance.
Best regards
Alexander

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by