Hello all,
I have matrix (a*b*n) (3d matrix), I would like to convert it into n 2D matrix (a*b). Can someone help me, please?
Jonathan

댓글 수: 2

Rik
Rik 2019년 12월 9일
Do you want to just select 1 slice, sum the slices, take the mean of the slices, do something else?
Jonathan Demmer
Jonathan Demmer 2019년 12월 9일
Thank you for your answer.
I would like to create n matrix with dimension(a*b) from a 3D matrix (a*b*n). n is the temporal parameters of the 3 d matrix, I would like that each time step is in a new 2D matrix. Is that clearer?

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

답변 (1개)

Matt J
Matt J 2019년 12월 9일

1 개 추천

Calling your matrix A,
Acell=num2cell(A,[1,2]);

댓글 수: 6

Jonathan Demmer
Jonathan Demmer 2019년 12월 9일
Hello,
Thank you for the answer, but it does not seem to work properly as it does not create n 2D matrix from a 3D matrix (a*b*n).
Matt J
Matt J 2019년 12월 9일
편집: Matt J 2019년 12월 9일
Yes, it does. Example,
>> A=rand(2,3,4);
>> Acell=num2cell(A,[1,2]); Acell=Acell(:)
Acell =
4×1 cell array
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}
Each Acell{i} behaves in all ways like a separate 2x3 image variable. It has its own memory block and everything.
Jonathan Demmer
Jonathan Demmer 2019년 12월 9일
How can i extract the value from each matrix?
Rik
Rik 2019년 12월 9일
Just as Matt wrote: use curly brackets.
Acell{2}
Matt J
Matt J 2019년 12월 9일
편집: Matt J 2019년 12월 9일
Jonathan Demmer's answer converted to a comment:
Thank you everybody, it work s well indeed...
Regards
Jonathan
Matt J
Matt J 2019년 12월 9일
You are welcome, but since it did work, please Accept-click the answer.

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2019년 12월 9일

댓글:

2019년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by