Wrong matrix multiplication answer

Hi, When I multiply a and b
a=[1 -2 0; 3 2 1; -2 1 3];
b=[4, -2 3;-1 5 0;6 1 2];
I get this answer
ans =
6 -12 3
16 5 11
9 12 0
The second row appears to be incorrect. When I do it by hand, the second row becomes [4 3 7]
I'm new to Matlab; is my syntax ok?

 Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 1 May 2013
Edited: Azzi Abdelmalek on 1 May 2013
I think you are doing something wrong by hand. The result
6 -12 3
16 5 11
9 12 0
is correct

5 Comments

My hand calculated answer matches the answer in the book. This is what I did. I used the same procedure and rows 1 and 3 match my answers. Please correct me if I did it wrong.
For row 2:
3*4+2*-1+-1*6 3*-2+2*5+-1*1 3*3+2*0+-1*2 = [4 3 7]
This is wrong, It's
[3*4+2*(-1)+1*6 3*(-2)+2*5+1*1 3*3+2*0+1*2]
Why -1*6?
a(2,3)=+1 and b(3,1)=+6, so the first element is
(3*4)+(2*-1)+(1*6) = 16
You're right. I left out one negative sign. I'm new to matrices so it's hard for me to figure out where the problem may lie. It's funny how you can compare the entered matrices with what's printed on the paper a dozen time and still not see the missing negative sign. Thank you for your help.
16 5 11 as the second row is the same answer that Maple gets.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!