简体   繁体   English

复杂值向量的MatLab点积无法正常工作

[英]MatLab dot product of complex valued vectors not working correctly

>> a = [a1 a2]

a =

   2.0000 + 0.0000i  -1.0000 + 1.7321i

>> b = [b1 b2]

b =

   2.0000 + 0.0000i  -1.0000 - 1.7321i

>> dot(a,b)

ans =

   2.0000 + 3.4641i

>> a1*b1+a2*b2

ans =

     8

Why am I getting such a weird value for taking the dot product of two complex valued vectors? 为什么取两个复数值向量的点积会得到这么奇怪的值? I am pretty sure the answer should be 8, but I still get 2.0000 + 3.4641i as shown above. 我很确定答案应该是8,但是我仍然得到2.0000 + 3.4641i,如上所示。 Am I doing something wrong? 难道我做错了什么?

From the documentation, 从文档中

dot(A,B) is the same as A'*B. 点(A,B)与A'* B相同。

so, if you try: 因此,如果您尝试:

a = [2.0000 + 0.0000i  -1.0000 + 1.7321i]
b = [2.0000 + 0.0000i  -1.0000 - 1.7321i]
dot(conj(a),b)

You'll get: 你会得到:

>> dot(conj(a),b)

ans =

    8.0002

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM