필터 지우기
필터 지우기

merging the matrices

조회 수: 5 (최근 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 CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by