How do I avoid a nested loop when assigning vales to a multidimensional structure in MATLAB 7.4 (R2007a)?
Show older comments
I have created a 2x4 structure and a 2x4 matrix like this:
s = repmat(struct('a', 0), 2, 4);
xx = [11 12 13 14;21 22 23 24];
Now I want to assign s(i,j).a = xx(i,j), and I would like to do it vectorized not with a nested loop like this:
for i = 1:2
for j = 1:4
s(i,j).a = xx(i,j);
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!