- integer scalar * integer scalar
- integer scalar * integer array
- integer scalar * double scalar
- integer scalar * double array
- integer array * integer scalar
- integer array * double scalar
- double scalar * integer scalar
- double scalar * integer array
- double array * integer scalar
Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar
1 次查看(过去 30 天)
显示 更早的评论
I m traying to create an NMF algorithm (the multiplicative update rules) to decompose an image ento 2 matrix, but a message error apperas "Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar" at line 5 . could u plz help me
V=imread('circuit.tif');
[m,n]= size(V);
for iter=1:Niter;
for W0 = rand (m,r);
H0 = h0.* (V*w0')./((w0'*w0)*h0 + (10^-9));
gradW = W*(H*H') - V*H';
gradH = (W'*W)*H - W'*V;
end
for h0=rand(r,n);
w0= w.*(V*h0')./(w0*h0*h0'+10^-9);
gradW = W*(H*H') - V*H';
gradH = (W'*W)*H - W'*V;
end
projnorm = ([norm(gradW(gradW<0 | W>0)); norm(gradH(gradH<0 | H>0))]);
if projnorm < tol*initgrad | iter == Niter | cputime-initt > timelimit,
fprintf('Iter = %d Final proj-grad norm %f\n', iter, projnorm);
break
end
W = W.*(V*H')./(W*(H*H'));
H = H.*(W'*V)./((W'*W)*H);
end
0 个评论
采纳的回答
Walter Roberson
2016-10-23
You use
for W0 = rand (m,r);
for is defined as proceeding along the columns of whatever is on the right hand side, so W0 will be set to columns of length m x 1, and that will happen r times.
However, it turns out that you never use W0 in your code, so the overall effect is as if you had just set up a loop to happen r times.
On the next line you have
H0 = h0.* (V*w0')./((w0'*w0)*h0 + (10^-9));
This makes use of a bunch of variables that we as readers do not know the definition of. Your variable w0 there is not the same as W0 because MATLAB is case sensitive.
We know that V is either 2 or 3 dimensional, and is an integer data type, as it was read in by imread(). You use it with a * operation with w0 . We can tell by context that w0 is intended to be a vector or a 2D array. If w0 is not a scalar, then you have a integer data class * a vector or array. But the * operation is not fully implemented for integer data classes: if you have an integer data class, the only permitted operations are:
or to put it another way, when one side of the * is an integer array (non-scalar), then the other side must be a scalar integer or scalar double, and it is not permitted to have a non-scalar integer array on one side and a non-scalar array of any kind on the other side.
The easiest fix:
V = double( imread('circuit.tif') );
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!