MATLAB Answers

0

sum of multiplication for a vector and matrix

Asked by Abbi Hashem on 27 Jun 2019
Latest activity Edited by Bruno Luong
on 27 Jun 2019
Say I have the following matrix and vector:
A = [ 2,3; 1,4] b= [ 5 , 7 ]
I want a code of the sum of the multiplication, such that each element of the matrix's first row are multiplied by the 1st cell of the vector, and the elements of the matrix's second row are multiplied by the 2nd cell of the vector, as follows:
2*5+3*5+1*7+4*7
( I will need this for a 1000*1000 matrix and a 1*1000 vector, but i used this example to clarify )

  0 Comments

Sign in to comment.

2 Answers

Answer by James Tursa
on 27 Jun 2019

result = sum(b*A);

  0 Comments

Sign in to comment.


Answer by Bruno Luong
on 27 Jun 2019
Edited by Bruno Luong
on 27 Jun 2019

b*sum(A,2)
Less operations than the first solution.

  0 Comments

Sign in to comment.