Error in Vector Multiplication of Complex Numbers
Ältere Kommentare anzeigen
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 Kommentare
"Does anyone know what's happening here, or do I miss some logics behind?"
>> 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
Yuling Shen
am 1 Okt. 2019
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Graphics Object Programming finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!