Error using reshape To RESHAPE the number of elements must not change.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 16 de Jun. de 2021
Editada: Walter Roberson
el 16 de Jun. de 2021
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 comentarios
Walter Roberson
el 19 de Jun. de 2021
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.
Ver también
Categorías
Más información sobre Graphics Object Programming 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!