merging the matrices

2 ビュー (過去 30 日間)
kash
kash 2012 年 3 月 20 日
i have two matrices
A=[1 5 10
10 20 30
2 5 6]
B=[ 25 1 2
2 5 9
1 0 5]
i want to merge these two matrices such that i need output as
C=[1 5 10
25 1 2
10 20 30
2 5 9
2 5 6
1 0 5]
please help

採用された回答

Daniel Shub
Daniel Shub 2012 年 3 月 20 日
reshape([A B]', 3, 6)'
ans =
1 5 10
25 1 2
10 20 30
2 5 9
2 5 6
1 0 5

その他の回答 (2 件)

Thomas
Thomas 2012 年 3 月 20 日
try
c=[];
for i=1:size(a)
d(:,:)=[a(i,:);b(i,:)];
c=[c;d];
end
c
  5 件のコメント
Thomas
Thomas 2012 年 3 月 20 日
I think you need to use..
for i=1:length(a), instead of size(a)
kash
kash 2012 年 3 月 21 日
Thanks thomas

サインインしてコメントする。


Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 20 日
C = [A B];
C = reshape(C',[],3)'
  2 件のコメント
kash
kash 2012 年 3 月 20 日
in ur code am not getting exact result
Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 20 日
I'm sorry. I mixed up the [] and the 3. It should read:
C = [A B];
C = reshape(C',3,[])'

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by