Apply a formula and create a new matrix

4 views (last 30 days)
Suppose I have 2 matrices :
x =
and y =
I am not able to figure out the code that will output a matrix which calculates the following:
  1 Comment
Star Strider
Star Strider on 27 Aug 2020
That looks like striaghtforward matrix-vector multiplication to me.

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 27 Aug 2020
Edited: Bruno Luong on 27 Aug 2020
b.'*sum(A,2)
sum(A,2).'*b % preferable than
sum(A.'*b) % or
sum(b.'*A) % or
sum(A.*b,'all')
or
s = 0;
for i=1:size(A,1)
for j=1:size(A,2)
s=s+A(i,j)*b(i);
end
end
s

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!