M is matrix of 2010x1300
how do i form 201 cells of 10x1300 using mat2cell?

 Respuesta aceptada

Star Strider
Star Strider el 31 de Oct. de 2017

1 voto

This works:
M = randn(2010, 1300);
C = mat2cell(M, 201*ones(1,10), 1300);
See the documentation for an explanation.

4 comentarios

Joseph Lee
Joseph Lee el 31 de Oct. de 2017
This produced 10 cells of 201x1300 instead of 201 cells of 10x1300
Star Strider
Star Strider el 31 de Oct. de 2017
Misread the Question.
Easily fixed:
M = randn(2010, 1300);
C = mat2cell(M, 10*ones(1,201), 1300);
Joseph Lee
Joseph Lee el 31 de Oct. de 2017
thanks!
Star Strider
Star Strider el 31 de Oct. de 2017
My pleasure!
Since my Answer solves the problem you originally posted, please Accept it!

Iniciar sesión para comentar.

Más respuestas (1)

M
M el 31 de Oct. de 2017

1 voto

Maybe not the easiest solution, but try something like :
j=1;
for i=1:10:201
A{j}=M(i:i+9,:);
j=j+1;
end

1 comentario

Joseph Lee
Joseph Lee el 31 de Oct. de 2017
Your solution worked but without the 10
for i=1:201
A{j}=M(i:i+9,:);
j=j+1;
end

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 31 de Oct. de 2017

Comentada:

el 31 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by