Error in Vector Multiplication of Complex Numbers

Hello,
I am running into a strange error in vector multiplication. Let's say I have the two variables, a = 2i and b = 1. It is clear that a^2+b^2 = -4+1 = -3.
However, when I write them in vector form, [a,b]*[a,b]', Matlab gives me an wrong answer, that is, [a,b]*[a,b]' = 5.
Does anyone know what's happening here, or do I miss some logics behind?
Thank you!

댓글 수: 2

Stephen23
Stephen23 2019년 10월 1일
편집: Stephen23 2019년 10월 1일
"Does anyone know what's happening here, or do I miss some logics behind?"
You are using conjugate tranpose, but you should use element-wise transpose:
>> a = 2i;
>> b = 1;
>> [a,b]' % conjugate transpose (what you are doing)
ans =
0 - 2i
1 - 0i
>> [a,b].' % transpose (what you should be doing)
ans =
0 + 2i
1 + 0i
Note you can trivially avoid the transpose anyway, by defining the vector as a column:
>> [a;b]
ans =
0 + 2i
1 + 0i
Hi Stephen,
Thanks very much for the explanation! This helps a lot!

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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 10월 1일
편집: Andrei Bobrov 2019년 10월 1일
>> [a,b]*[a;b]
ans =
-3
>> [a,b]*[a,b].'
ans =
-3
>> [a,b]*transpose([a,b])
ans =
-3
>> [a,b].'
ans =
0 + 2i
1 + 0i
>> [a,b]'
ans =
0 - 2i
1 + 0i
>> transpose([a,b])
ans =
0 + 2i
1 + 0i
>> ctranspose([a,b])
ans =
0 - 2i
1 + 0i
>>

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

질문:

2019년 10월 1일

댓글:

2019년 10월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by