How i can combine three or more than three matrix?
조회 수: 2 (최근 30일)
이전 댓글 표시
y=[repmat(x1,size(x2,1),1),repelem(x2,size(x1,1),1)];
I am writing this code for combining two matrix where the row number is different but column is same .
My question is how i can combine more than two matrix where their row number is differnt but column is same ?
댓글 수: 0
채택된 답변
Stephen23
2021년 8월 10일
편집: Stephen23
2021년 8월 10일
Note that you will run out of memory very quickly as you increase the number of matrices.
format compact
inp = {rand(3,4),rand(4,4),rand(5,4)}; % all matrices in one cell array.
celldisp(inp)
fun = @(m)1:size(m,1);
idr = cellfun(fun,inp,'uni',0);
[idr{:}] = ndgrid(idr{:}); % comma-separated lists
baz = @(m,r)m(r(:),:);
tmp = cellfun(baz,inp,idr,'uni',0);
out = horzcat(tmp{:})
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!