131 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

Opportunities for recent engineering grads.

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

Start Hunting!
## 3 Comments

## Direct link to this comment

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

⋮## Direct link to this comment

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

## Direct link to this comment

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

⋮## Direct link to this comment

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

## Direct link to this comment

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

⋮## Direct link to this comment

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

Sign in to comment.