Search code examples
matlabmatrix-multiplicationcomplex-numbers

Confusions about Multiplication of Complex Value in MatLab


I noticed a confused computation of complex valued multiplication in Matlab. One simple example is as below:

syms x1 x2 x3 x4
s=[x1 x2]*[x3 x4]'

And the return value of s is like:

s=x1*conj(x3) + x2*conj(x4)

In my opinion s should be equal to x1*x3+x2*x4. So, what's the problem here?

Then, how should I do if I want to get a multiplication of two complex vector?

update: I find out it will be solved through using .' rather than . like:

s=[x1 x2]*[x3 x4]

Solution

  • The operator ' is the also called Complex conjugate transpose in Matlab ctranspose, which basically means that it applies conj and and transpose functions. Note that this operator is call Hermitian operator in mathematics.

    What you actually want is the operator transpose that is shortcut as .'

    In order to get the expected output, and given that you just want to multiply without conjugating the second vector, you should do:

    >> syms x1 x2 x3 x4
    >> s = [x1 x2]*[x3 x4].'
    

    so your output will be:

    x1*x3 + x2*x4
    

    For further information you can check help ., to see the list of operators, help transpose and help ctranspose