adding multiple arrays into one big array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kafayat Olayinka
am 8 Aug. 2019
Kommentiert: Kafayat Olayinka
am 8 Aug. 2019
Hi,
I have multiple array with different sizes such as A1=(200 by 3000),A2=(280 by 3020).
I will like to create a zeros matrix: A=zeros(480 by 3020) where i'm able to stack each rows of A1 and A2 inside the new array A.
Such that A=[A1;A2]
what should i do?
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 8 Aug. 2019
Bearbeitet: Andrei Bobrov
am 8 Aug. 2019
s1 = size(A1);
s2 = size(A2);
s22 = max(s1(2),s2(2));
A = [A1,zeros(s1(1),s22 - s1(2));A2,zeros(s2(1),s22 - s2(2))];
3 Kommentare
Andrei Bobrov
am 8 Aug. 2019
Let C = {A1,A2,A3,..,An}';
[m,n] = cellfun(@size,C,'un',0);
nn = max([n{:}]);
A = cell2mat(cellfun(@(x,y,z)[x,zeros(y,nn-z)],C,m,n,'un',0));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Types 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!