Convert matrix 3d into 2d
古いコメントを表示
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
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
2019 年 12 月 9 日
回答 (1 件)
Matt J
2019 年 12 月 9 日
Calling your matrix A,
Acell=num2cell(A,[1,2]);
6 件のコメント
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).
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
2019 年 12 月 9 日
How can i extract the value from each matrix?
Rik
2019 年 12 月 9 日
Just as Matt wrote: use curly brackets.
Acell{2}
Matt J
2019 年 12 月 9 日
You are welcome, but since it did work, please Accept-click the answer.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!