how to solve this error?
Show older comments
Hi , can you help please to solve this problem :
Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar. To compute elementwise TIMES, use TIMES (.*) instead.
Error in cameramanlinenoisy0202combine (line 128) alphaB=VB*Z';
Best regards
Answers (2)
It's hard to know exactly what your code is, but if you do what it says in the error message it may fix your problem if your matrices are of the correct size.
i.e.
alphaB=VB.*Z';
but without knowing the code and what size VB and Z are I can't be certain. If they are totally incompatible size then using .* will not work either.
The * operator is used for multiplying something by a scalar or doing matrix multiplication. If you have two matrices of the same size and you wish to do an element by element multiplication then you need to use the .* operator which does this. It also will not work though if you are trying to multiply a 3*6 matrix by a 4*5 matrix because there is no logical interpretation of what you are trying to multiply.
Walter Roberson
on 2 Feb 2016
In the line
alphaB=VB*Z';
one of VB or Z is your image array, with VB being more likely. Whichever one it is, you need to convert to double precision. Try
alphaB = double(VB) * double(Z)';
2 Comments
Vishnupriya C
on 25 Sep 2016
i have used double but it shows the error as out of memory.can anyone suggest a solution?
Walter Roberson
on 25 Sep 2016
Remember that when you use A * B, that the size of the output array will be size(A,1) by size(B,2) -- the number of rows of the first by the number of columns of the second. That might require more memory than you have available. The temporary memory required for the calculation should be at most a vector max(size(A,1),size(B,1)) long.
You should check to see if what you need is instead A .* B, which is element-by-element multiplication, A(I,J) * B(I,J)
Generally when you do matrix multiplication using * the precision required for the output exceeds the precision of the input. If you are working with large matrices such that double() of the output will be too large for your memory but in native precision it would not be too large, and you are certain that the result of multiplication will not exceed the original precision, then you can do the multiplication in "chunks". For example instead of A * B you can do
out = zeros(size(A,1), size(B,2), class(A));
dB = double(B);
for row = 1 : size(A,1)
out(row,:) = double(A(row,:)) * dB;
end
clear dB
This reduces the amount that has to be converted to double precision at any one time to be size(B) together with a vector size(A,2) . If your B is notably bigger than your A then you can use a similar kind of manipulation to instead take double(A) as your working matrix.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!