MATLAB Answers

0

Issues in Matrix multiplication

Asked by Nikolaos Zafirakis on 16 Apr 2019
Latest activity Edited by Matt J
on 16 Apr 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?

  0 Comments

Sign in to comment.

2 Answers

Matt J
Answer by Matt J
on 16 Apr 2019
Edited by Matt J
on 16 Apr 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);

  0 Comments

Sign in to comment.


Matt J
Answer by Matt J
on 16 Apr 2019
Edited by Matt J
on 16 Apr 2019

Use mtimesx from the File Exchange
Example:
A=rand(6,6,100);
B=rand(6,1,100);
C=mtimesx(A,B);

  0 Comments

Sign in to comment.