68 views (last 30 days)

Moe_2015
on 6 Jun 2016

Edited: Moe_2015
on 6 Jun 2016

That is not how matrix multiplication works at all. For a matrix and a vector:

A= [1 2 v= [1

3 4] -1]

A*v= [1*1+2*(-1)

3*1+4*(-1)]

MATLAB does not fail. It does it correctly.

Please review matrix multiplication:

Moe_2015
on 6 Jun 2016

ok, for what you want (which is not matrix multiplication) you could do the following:

A=[1,2;3,4];

v=[1;-1];

result=sum(A,1)'.*v

which gives:

result =

4

-6

Stephen Cobeldick
on 7 Jun 2016

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/288055-2x2-matrix-multiplied-by-a-2x1-column-vector-gives-erratic-results#comment_371266

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/288055-2x2-matrix-multiplied-by-a-2x1-column-vector-gives-erratic-results#comment_371266

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/288055-2x2-matrix-multiplied-by-a-2x1-column-vector-gives-erratic-results#comment_371269

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/288055-2x2-matrix-multiplied-by-a-2x1-column-vector-gives-erratic-results#comment_371269

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/288055-2x2-matrix-multiplied-by-a-2x1-column-vector-gives-erratic-results#comment_371345

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/288055-2x2-matrix-multiplied-by-a-2x1-column-vector-gives-erratic-results#comment_371345

Sign in to comment.