I Want to perform element wise matrix multiplication

24 次查看(过去 30 天)
I have used the following code but getting an error message
I1=imread('abc.gif');
a=I1(1:3,1:3);
b=[-3 4 5;6 -7 1;-2 -4 -6];
c=a.*b;
The error message obtained is listed below Error using .* Integers can only be combined with integers of the same class, or scalar doubles.
How to clear this error

采纳的回答

KSSV
KSSV 2017-6-12
I1=imread('abc.gif');
a=I1(1:3,1:3);
b=uint8([-3 4 5;6 -7 1;-2 -4 -6]);
c=a.*b;
You see you can multiply only same classes. Class of a is uint8, so you need to convert b into the same class.

更多回答(1 个)

Muhammed Musa
Muhammed Musa 2020-11-26
A = [1 2 3 4];
B = [9 8 7 6];
A.*B =

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by