How to divide matrix with dimension 300x564 to many submatrices

1 visualización (últimos 30 días)
nadia nadi
nadia nadi el 19 de Sept. de 2015
Editada: nadia nadi el 21 de Sept. de 2015
Dear,
I tried to divided a matrix with dimension 300x564 to four or two or even 12 matrices in this code but it give error while for a matrix 500x500 or 100x100 it ok. I change h to the number of sub matrices I want. I have problem with reshape.
[m,n]=size(res);
h=2;
nn=fix(n/(n/h));
m1=n-nn;
res(:,end+1:end+mod(2-m1,2))=nan;
A=res(:,1:end);
B=reshape(A,n,n/h,[]);
[m,n,p]=size(B);
OUT=zeros(m,n,p);
I got this error.
Error using reshape Product of known dimensions, 79524, not divisible into total number of elements, 169200.
Error in SRBM (line 22)
B=reshape(A,n,n/4,[]);
and Error using reshape Product of known dimensions, 159048, not divisible into total number of elements, 169200, if I want to divide for two submatrices.
thanks for any help.
Nadia

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Sept. de 2015
B=reshape(A,n/h,h,[]);
  1 comentario
nadia nadi
nadia nadi el 19 de Sept. de 2015
Editada: nadia nadi el 21 de Sept. de 2015
Dear Walter,
I wrote it like this
[m,n]=size(res);
h=4;
nn=fix(n/(n/h));
m1=n-nn;
res(:,end+1:end+mod(2-m1,2))=nan;
A=res(:,1:end);
B=reshape(A,m,n/h,[]);
Now it works.
many thanks,
Nadia

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by