How do I avoid a nested loop when assigning vales to a multidimensional structure in MATLAB 7.4 (R2007a)?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!