sum of multiplication for a vector and matrix

조회 수: 6 (최근 30일)
Abbi Hashem
Abbi Hashem 2019년 6월 27일
편집: Bruno Luong 2019년 6월 27일
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 )

답변 (2개)

James Tursa
James Tursa 2019년 6월 27일
result = sum(b*A);

Bruno Luong
Bruno Luong 2019년 6월 27일
편집: Bruno Luong 2019년 6월 27일
b*sum(A,2)
Less operations than the first solution.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by