MATLAB Answers

how can I create a struct with row vectors

2 views (last 30 days)
Tianyu Cheng
Tianyu Cheng on 27 Nov 2020
Commented: Tianyu Cheng on 27 Nov 2020
I create a struct:
gt_tracks(num_gt_tracks) = struct('Position', [], 'Velocity', []);
for j = 1:num_gt_tracks
gt_tracks(j).Position = [gt(j,2:3), 0];
gt_tracks(j).Velocity = zeros(3,1);
but in this code:
OSPA(t) = OSPAMetric(tracks, gt_tracks);
OSPA requires 'Position' and 'Velocity' fields must be row vectors.
so what should i do?

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 27 Nov 2020
It is quite straightforward to create row vector components for a Structure array. E.g.:
t=linspace(0,13, 131);
GT.Pos = randi([-13, 13],1, 131);
GT.Vel = 2.5*t-5;
Tianyu Cheng
Tianyu Cheng on 27 Nov 2020
because the way i uesd create a column vector

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!