how to convert a matrix to a cell array

161 visualizaciones (últimos 30 días)
John
John el 30 de Jul. de 2012
Comentada: william katzianer el 21 de Jul. de 2020
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

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 30 de Jul. de 2012
Editada: Andrei Bobrov el 30 de Jul. de 2012
please read about functions num2cell and mat2cell
eg:
out = num2cell(yourmatrix,1)
or
out = mat2cell(yourmatrix,2,ones(1,size(yourmatrix,2)))
  1 comentario
Raphael
Raphael el 17 de Mayo de 2013
Dear,
Do you know how to save the cell array created by the function?
Best regards,
Raphael

Iniciar sesión para comentar.

Más respuestas (1)

venkat vasu
venkat vasu el 30 de Jul. de 2012
Editada: Walter Roberson el 30 de Jul. de 2012
X= reshape(1:20,2,10)'
C = mat2cell(X, [1,10],[2,1]);
celldisp(C);

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by