concatenating the several matrices in a certain manner
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello all,
I have N J matrices all with the same size. I would like to concatenate them in a way such that I would get a new matrix C with its first J columns be the first row of the J matrices, the second J columns of C consist of second column of all the J matrices and so on. For instance suppose J=2 and I have the following two matrices: s1=[0 0 1 1;1 1 0 0;1 1 0 0;0 0 1 1]; s2=[0 0 -1 -1;-1 -1 0 0;-1 -1 0 0;0 0 -1 -1]; I would like to have C=[0 0 0 0 1 -1 1 -1;1 -1 1 -1 0 0 0 0;1 -1 1 -1 0 0 0 0;0 0 0 0 1 -1 1 -1]; I would appreciate any help!
0 Kommentare
Akzeptierte Antwort
Stephen23
am 9 Nov. 2015
Bearbeitet: Stephen23
am 9 Nov. 2015
>> s1=[0 0 1 1;1 1 0 0;1 1 0 0;0 0 1 1]
s1 =
0 0 1 1
1 1 0 0
1 1 0 0
0 0 1 1
>> s2=[0 0 -1 -1;-1 -1 0 0;-1 -1 0 0;0 0 -1 -1]
s2 =
0 0 -1 -1
-1 -1 0 0
-1 -1 0 0
0 0 -1 -1
>> C = [];
>> C(:,2:2:8) = s1;
>> C(:,1:2:8) = s2
C =
0 0 0 0 -1 1 -1 1
-1 1 -1 1 0 0 0 0
-1 1 -1 1 0 0 0 0
0 0 0 0 -1 1 -1 1
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!