필터 지우기
필터 지우기

Convert a 3D array to a 2D cell array?

조회 수: 10 (최근 30일)
Niky Taylor
Niky Taylor 2017년 10월 13일
댓글: Niky Taylor 2017년 10월 16일
I'm sure there's a basic way to do this that I haven't found.
I have a 3D array, but I want to convert it into a 2D cell array where each cell contains the data currently contained in the 3rd dimension, so:
if given some 3D array A = rand(10,10,4);
make a 2D cell array B that is 10x10 cells, but each cell contains 1x4.
Thanks so much.

채택된 답변

Matt J
Matt J 2017년 10월 13일
B=num2cell(A,3)
  댓글 수: 2
Matt J
Matt J 2017년 10월 13일
but each cell contains 1x4.
If you really do need a 1x4 shape, you can do
[m,n,p]=size(A);
B=num2cell(reshape(A,[],p), 2);
B=reshape(B,m,n);
Niky Taylor
Niky Taylor 2017년 10월 16일
Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by