merging the matrices
显示 更早的评论
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
采纳的回答
更多回答(2 个)
Thomas
2012-3-20
try
c=[];
for i=1:size(a)
d(:,:)=[a(i,:);b(i,:)];
c=[c;d];
end
c
5 个评论
kash
2012-3-20
Daniel Shub
2012-3-20
What error do you get. Does it fail for a 4x3 matrix? Can you post a minimal example of the failure?
Thomas
2012-3-20
I tried this on two 25x64 matrices and it still works.. What error are you getting..
Thomas
2012-3-20
I think you need to use..
for i=1:length(a), instead of size(a)
kash
2012-3-21
Jonathan Sullivan
2012-3-20
C = [A B];
C = reshape(C',[],3)'
2 个评论
kash
2012-3-20
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,[])'
类别
在 帮助中心 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!