Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Arif Hoq
Arif Hoq am 19 Feb. 2022
Bearbeitet: Arif Hoq am 19 Feb. 2022
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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by