- a(:,:,end+1) = randi(10,2,3); ~OR~
- a = cat(3,a,randi(10,2,3));
help in multi dimensional array 3D
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kawther Alani
am 17 Jan. 2017
Kommentiert: Kawther Alani
am 18 Jan. 2017
hi I'm trying to increase the third dimension in a three-dimensional matrix can you help me? Example a=(2,3,5) after iteration it must be a=(2,3,7) thanks
0 Kommentare
Akzeptierte Antwort
Greg
am 17 Jan. 2017
Bearbeitet: Greg
am 17 Jan. 2017
I assume that "a=(2,3,5)" means the corresponding length of each dimension of a is 2, 3 and 5.
Increasing variable size is rarely a good idea (there are plenty of articles on pre-allocation; I won't rehash).
a = zeros(2,3,7);
for ind3 = 1:7
a(:,:,ind3) = randi(10,2,3);
end
(But ALL of this trivial example can be done with "a = randi(10,2,3,7);")
If you really MUST dynamically allocate:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!