I have in total 4 matrices each of size (m)x(n)x(p) .. Lets say these matrices are called a,b,c and d.
I need to combine them in such a way that I would get a resulting matrix of size 2m x 2n x 2p, with the 2m coming from a and b, 2n from a and c, and 2p from a and d.
I can get the corresponding 2m x n x p and etc. using cat(1,a,b), cat (2,a,c) etc, but am unable to figure out the rest (or if this is even the right direction). Any help is appreciated.
Thanks!

답변 (1개)

Matt J
Matt J 2019년 4월 2일
편집: Matt J 2019년 4월 2일

4 개 추천

Your description doesn't define the new matrix well enough. The result will have 8 times as many entries, but you only have 4 matrices to draw data from, so it is not clear where all the additional entries will come from.
However, here is one of many possibilities,
L1=[a,c;b,c];
L2=[d,d;d,d];
result=cat(3,L1,L2);

댓글 수: 3

Prodip Das
Prodip Das 2019년 4월 3일
편집: Prodip Das 2019년 4월 4일
EDIT: Sorry for the confusion, there are (have to be) 8 matrices in-fact - As correctly pointed out by you. I had to combine them (matrices a-h) in specific order - which I got by doing something as simple as
N(1:2:m*2, 1:2:n*2, 1:2:p*2) = a(:,:,:);
N(2:2:m*2, 1:2:n*2, 1:2:p*2) = b(:,:,:);
N(1:2:m*2, 2:2:n*2, 1:2:p*2) = c(:,:,:);
and so on for the rest... resulting in N being the 2mx2nx2p matrix.
Thanks!
I can remove/edit this query if this seems redundant now.
Paulo Eduardo Beiral
Paulo Eduardo Beiral 2021년 7월 8일
Thank you, it helped me too!
Matt J
Matt J 2021년 7월 8일
I'm glad, but if so please Accept-click the asnwer.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2019년 4월 2일

댓글:

2021년 7월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by