フィルターのクリア

concatenating the several matrices in a certain manner

2 ビュー (過去 30 日間)
Mnr
Mnr 2015 年 11 月 9 日
編集済み: Stephen23 2015 年 11 月 9 日
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!

採用された回答

Stephen23
Stephen23 2015 年 11 月 9 日
編集済み: Stephen23 2015 年 11 月 9 日
>> 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 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by