I have these 2 vectors:
alpha =
1 1 1 1 1 1 1 1 1
f_uv =
193 193 194 192 193 193 190 189 191
And when I do this:
alphaf_uv = alpha * f_uv'
I get the error message:
"??? Error using ==> mtimes
Integers can only be combined with integers of the same class, or scalar doubles."
The interesting part is that this error doesn't appear if I define the same vectors in the console and try the multiplication there.
alpha
is defined by me and f_uv
is obtained from some pixels in a PNG image.
C = A . * B multiplies arrays A and B by multiplying corresponding elements. The sizes of A and B must be the same or be compatible. If the sizes of A and B are compatible, then the two arrays implicitly expand to match each other.
A = [1 1 0 0]; B = [1; 2; 3; 4]; Multiply A times B . The result is a 1-by-1 scalar, also called the dot product or inner product of the vectors A and B . Alternatively, you can calculate the dot product A ⋅ B with the syntax dot(A,B) .
Assuming they're both integer matrices to begin with, f_uv'
may not be.
Try:
alphaf_uv = double(alpha) * double(f_uv')
and let us know if it still occurs.
You may need to turn alphaf_uv
back into an integer type afterwards, depending on your needs.
The big clue here is this:
alpha is defined by me and f_uv is obtained from some pixels in a png image.
This heavily implies that the f_uv data is coming in as uint8. The WHOS command will verify. When you define this at the command line, the vectors will be Double by default. That is why you are seeing the difference in behavior between "identical" matrices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With