num2cell question regarding condensing

조회 수: 2 (최근 30일)
ampaul
ampaul 2018년 1월 26일
답변: Walter Roberson 2018년 1월 26일
Hello all,
I have a simple question, but I am having trouble finding the most simple way to accomplish this task.
Let's say A is a 10x25 double. I am trying to use "num2cell" to create a 25x1 cell that contains one column of 25 1x10 doubles.
So far I have tried
C = num2cell(A,25)
Unfortunately, that just leaves me with a 10*25 cell. Does anyone know how to correct this?
Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 26일
cellfun(@transpose, num2cell(A,1), 'uniform', 0)
The transpose is to get them from 10 x 1 into 1 x 10

추가 답변 (1개)

Rik
Rik 2018년 1월 26일
편집: Rik 2018년 1월 26일
You can use mat2cell:
C=mat2cell(A,[10],ones(25,1))

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by