Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Arif Hoq
Arif Hoq el 19 de Feb. de 2022
Editada: Arif Hoq el 19 de Feb. de 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

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by