How to multiply matrix with matrix, only between their component counterparts

3 次查看(过去 30 天)
Hi,
if I have matrices A and B
A=[ 1 2 ; 3 4]
B=[10 20; 30 40]
are there a fast/straightforward operation in which the result is matrix C
C=[1x10 2x20 ; 3x30 4x40] ?
Obviously, calculation with 4 loops is what I would like to avoid.
Thank you in advance.

采纳的回答

Arif Hoq
Arif Hoq 2022-2-19
编辑:Arif Hoq 2022-2-19
you need to multiplication element by element. you should use a dot (.) before any multiplication (*), division (/), or power (^) operators that involve vectors.
A=[ 1 2 ; 3 4];
B=[10 20; 30 40];
C=A.*B
C = 2×2
10 40 90 160

更多回答(0 个)

类别

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