What's the difference between two way to input Matlab Complex Matrices
Asked Answered
M

1

2

Here's two ways to enter the command in Matlab. I don't think there's any difference between them. However, the result is really different. So I wonder what's I missed in this situation.

Here's the first input:

>> A = [(-0.025+0.01i) -0.025;
   3 (1-2i)];
>> B = [(5.7955+1.5529i) 0]';
>> I=inv(A)*B

The output is like this:

I =

   1.0e+02 *

  -0.7063 - 1.2723i
  -1.1030 + 1.6109i

Here's the second input:

>> A = [(-0.025+0.01i) -0.025;3 (1-2i)];
>> B = [(5.7955+1.5529i);0];
>> I=inv(A)*B

And the Matlab give me the result below:

I =

           2.44764705882354 -      145.499411764706i
          -176.067882352941 +      84.3624705882353i

I'm really confused about this situation. If you know anything please let me know about it. Thanks.

Mana answered 7/5, 2014 at 5:14 Comment(3)
And to be even more clear: Don't use inv. I = A\B is the "correct" way to do this. According to The Mathworks, you should only use inv when you actually want to see the inverse matrix, and not when solving something like inv(A)*B;. (Doesn't answer your question though)Sweetheart
@Divakar It is actually called hermitian transpose or conjugate transpose, but otherwise it is clear, any reason that, you have not posted it as an answer already, to be able to close the question?Outpatient
@Outpatient My general idea is that if I am suggesting a correction, it's better as comments. But yes at the sametime, we need to think of closing questions too! Thanks on the terminology there! Posted those as an answer.Chromogenic
C
4

Use B = [(5.7955+1.5529i) 0].' which is actually element-wise transpose and not B = [(5.7955+1.5529i) 0]' which is conjugate transpose.

One can also use an explicit call to transpose command - B = transpose([(5.7955+1.5529i) 0])

Chromogenic answered 7/5, 2014 at 6:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.