Error using reshape To RESHAPE the number of elements must not change.
1 回表示 (過去 30 日間)
古いコメントを表示
can anyone tell me where is the error?
yw=Eband;
k=NoOfBands;
xrtemp=reshape(Eband(k),1,S(1,1)*S(1,2));
k=k-1;
for i=2:size(S,1)-1
xrtemp=[xrtemp reshape(Eband(k-1),1,S(i,1)*S(i,2)) reshape(Eband{k},1,S(i,1)*S(i,2)) reshape(Eband{k-2},1,S(i,1)*S(i,2))];
k=k-3;
end
DImg=(waverec2(xrtemp,S,wname));
nl_mnt=im_nl+DImg;
nl_mnt8=uint8(nl_mnt);
toc
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 6 月 16 日
編集済み: Walter Roberson
2021 年 6 月 16 日
k=NoOfBands;
That has the appearance of being a scalar.
xrtemp=reshape(Eband(k),1,S(1,1)*S(1,2));
We do not know what Eband is. If it is numeric or cell, then if k is a scalar then Eband(k) would be a scalar. You would then be attempting to reshape a scalar to be 1 by something, but that something does not look likely to happen to exactly equal 1.
If Eband is a function, then the previous like
yw=Eband;
would have been an invocation of the function without passing in any parameters. It could work and still have Eband(k) work, but it is not obvious that it will.
If Eband is the handle to a function, then the assignment to yw would be assigning a copy of the handle, and Eband(k) would be invoking the function. We cannot rule it out.
But let us look at
xrtemp=[xrtemp reshape(Eband(k-1),1,S(i,1)*S(i,2)) reshape(Eband{k},1,S(i,1)*S(i,2)) reshape(Eband{k-2},1,S(i,1)*S(i,2))];
and notice that Eband{k} and Eband{k-2} are referenced. Those are cell array references. We can then guess that the code you wanted was
xrtemp=reshape(Eband{k},1,S(1,1)*S(1,2));
If so that could also be written as
xrtemp = Eband{k}(:).';
6 件のコメント
Walter Roberson
2021 年 6 月 19 日
nl = S(1,1) = 32, nc = S(1,2) = 32, and there are not at least 3 columns in the S matrix.
In this configuration, the code expects to be reconstructing a 32 x 32 signal, and so needs xrtemp to have at least 32*32 = 1024 entries. But xrtemp only has 13 entries.
The way you build xrtemp is not compatible with the S matrix you have.
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!