Confusion with complex numbers manipulation in MATLAB
I'm confused with the manipulation of complex numbers in MATLAB. I have EE
is a 9x4
real matrix which I want to multiply with a complex 10x3
matrix SOLS
. The nitial code in Matlab is:
Evec= EE*[SOLS' ; ones(1,10 ) ];
This line is normally equivalent to:
SOLSt=SOLS';
for i=1:9
for j=1:10
Evec(i,j)=EE(i,1)*SOLSt(1,j)+EE(i,2)*SOLSt(2,j)+EE(i,3)*SOLSt(3,j)+EE(i,4);
end
end
Why the above loop dosen't give the same result as:
for i=1:9
for j=1:10
RE(i,j)=EE(i,1)*real(SOLSt(1,j))+EE(i,2)*real(SOLSt(2,j))+EE(i,3)*real(SOLSt(3,j))+EE(i,4);
IM(i,j)=EE(i,1)*imag(SOLSt(1,j))+EE(i,2)*imag(SOLSt(2,j))+EE(i,3)*imag(SOLSt(3,j))+EE(i,4);
end
end
Evec=complex(RE,IM);
When I did SOLSt=SOLS'
we did a conjugate transpose, that's OK. Now, for the multiplication of the real matrix EE
with the complex matrix SOLSt
which is the conjugate transpose of SOLS
. Mathematically, it gives an imaginary number which real part refers to the product of EE(i)
and Real(SOLSt(i))
and its imaginary part refers to the product of EE(i)
and imag(SOLSt(i))
which is translated by the second version mentioned above, but this gives a different result from the first version which is also the multiplication of EE(i)
with SOLSt(i)
..What I understood from this difference in results is that when i write EE(i)*SOLSt(i)
Matlab dosen't perform exactly the product of real part and imaginary parts. I don't want to use SOLS'.
, I just want to find the same result with the initial command Evec= EE*[SOLS' ; ones(1,10 ) ];
Evec= EE*[SOLS' ; ones(1,10 ) ];
not using .'
in a different way
In the line where you complex part of Evec
, you inluded EE(i,4)
in the sum. This shouldn't be there as it only exists in the real part of the solution. Things work fine if you use this instead:
IM(i,j)=EE(i,1)*imag(SOLSt(1,j))+EE(i,2)*imag(SOLSt(2,j))+EE(i,3)*imag(SOLSt(3,j));
链接地址: http://www.djcxy.com/p/24382.html
下一篇: 与MATLAB中的复杂数字操作混淆