3D array to cell array

조회 수: 31 (최근 30일)
Ali G
Ali G 2019년 4월 18일
답변: Star Strider 2019년 4월 18일
If I had a 3D array of 550x129x3, how would I transform this into a cell array consisting of 3 cells in the array which contains 550x129 corresponding to it? I looked at the num2cell documentation and it doesn't mention how to organise it into that format.

채택된 답변

Star Strider
Star Strider 2019년 4월 18일
Use the mat2cell (link) function:
A = rand(550, 129, 3); % Create Matrix
C = mat2cell(A, size(A,1), size(A,2), ones(1,size(A,3))); % Cell Array
Check = cell2mat(cellfun(@size, C, 'Uni',0)) % Check (Delete Later)
producing:
Check(:,:,1) =
550 129
Check(:,:,2) =
550 129
Check(:,:,3) =
550 129

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by