Issues in Matrix multiplication

3 vues (au cours des 30 derniers jours)
Nikolaos Zafirakis
Nikolaos Zafirakis le 16 Avr 2019
Modifié(e) : Matt J le 16 Avr 2019
I have 100 6 by 6 matrices and 100 6 by 1 matrices and I want to multiply them. If I do X=A.*B it does not give me the correct solution. Does anyone know a way around this?

Réponses (2)

Matt J
Matt J le 16 Avr 2019
Modifié(e) : Matt J le 16 Avr 2019
A somewhat less efficient solution (but which uses no 3rd party files) is,
A=rand(6,6,100);
B=rand(6,1,100);
C=sum( A.*reshape(B,1,6,[]) ,2);

Matt J
Matt J le 16 Avr 2019
Modifié(e) : Matt J le 16 Avr 2019
Use mtimesx from the File Exchange
Example:
A=rand(6,6,100);
B=rand(6,1,100);
C=mtimesx(A,B);

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by