Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

how to convert a matrix to a cell array

Asked by John on 30 Jul 2012

Hi there,

I have a 2x10 matrix. Would anybody know how I could convert it into a 1x10 cell array - so that each cell contains a 2x1 matrix?

I'm new to matlab and would appreciate any help.

Kind Regards

John

0 Comments

John

Products

No products are associated with this question.

2 Answers

Answer by Andrei Bobrov on 30 Jul 2012
Edited by Andrei Bobrov on 30 Jul 2012
Accepted answer

please read about functions num2cell and mat2cell

eg:

out = num2cell(yourmatrix,1)

or

out = mat2cell(yourmatrix,2,ones(1,size(yourmatrix,2)))

1 Comment

Raphael on 17 May 2013

Dear,

Do you know how to save the cell array created by the function?

Best regards,

Raphael

Andrei Bobrov
Answer by venkat vasu on 30 Jul 2012
Edited by Walter Roberson on 30 Jul 2012
X= reshape(1:20,2,10)'
C = mat2cell(X, [1,10],[2,1]);
celldisp(C);

0 Comments

venkat vasu

Contact us