how can i add two matrix vertically with different column
이전 댓글 표시
Hello,
how can i add two matrix vertically with different column?
please help
thank you
like this example:
A=[1 3 6 8 9]
B=[1 2]
Result= 1 3 6 8 9
1 2 0 0 0
댓글 수: 2
darova
2019년 9월 12일
What have you tried already? What problems do you have?
eli karimi
2019년 9월 12일
채택된 답변
추가 답변 (2개)
Adam Danz
2019년 9월 12일
Bpad = padarray(B,[0,numel(A)-numel(B)],'post');
C = [A;Bpad]
Bruno Luong
2019년 9월 12일
I would do with the old well-served for-loop
C={A B}; % put the list of your matrices here
m=cellfun('size',C,1);
n=cellfun('size',C,2);
Results=zeros(sum(m),max(n));
r=0;
for k=1:length(C);
Results(r+(1:m(k)),1:n(k))=C{k};
r=r+m(k);
end
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!