フィルターのクリア

How to divide matrix with dimension 300x564 to many submatrices

1 回表示 (過去 30 日間)
nadia nadi
nadia nadi 2015 年 9 月 19 日
編集済み: nadia nadi 2015 年 9 月 21 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 9 月 19 日
B=reshape(A,n/h,h,[]);
  1 件のコメント
nadia nadi
nadia nadi 2015 年 9 月 19 日
編集済み: nadia nadi 2015 年 9 月 21 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by