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?

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 1일
편집: Azzi Abdelmalek 2013년 5월 1일

3 개 추천

I think you are doing something wrong by hand. The result
6 -12 3
16 5 11
9 12 0
is correct

댓글 수: 5

Poon
Poon 2013년 5월 1일
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]
Matt J
Matt J 2013년 5월 1일
Why -1*6?
a(2,3)=+1 and b(3,1)=+6, so the first element is
(3*4)+(2*-1)+(1*6) = 16
Poon
Poon 2013년 5월 1일
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.
Walter Roberson
Walter Roberson 2013년 5월 1일
16 5 11 as the second row is the same answer that Maple gets.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by