dlmread complex number - sign inverted

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

dlmread complex number - sign inverted

inor0627
Hello,

I tried to read a text file (complex.txt) containing complex numbers:
0; 3+4i; 22

the commands:
format free;
dlmread('complex.txt',';')'
result in:
ans =
 (0,-0)
 (3,-4)
 (22,-0)

All number are converted to complex numbers, that's okay for me. But why is
the sign of the imaginary part of 3+4i inverted? Is this the expected
result?
The behaviour is the same for 4.2.1-64 on Win10 as well as 3.8.2 on debian
8.

Ingo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: dlmread complex number - sign inverted

siko1056
inor0627 wrote

> Hello,
>
> I tried to read a text file (complex.txt) containing complex numbers:
> 0; 3+4i; 22
>
> the commands:
> format free;
> dlmread('complex.txt',';')'
> result in:
> ans =
>  (0,-0)
>  (3,-4)
>  (22,-0)
>
> All number are converted to complex numbers, that's okay for me. But why
> is
> the sign of the imaginary part of 3+4i inverted?[...]

Dear Ingo,

This behavior is very expected, but fools me (this time again) often as
well.  The '-Operator is the complex conjugate transposition [1].

Thus

dlmread('complex.txt',';')
ans =

 (0,0) (3,4) (22,0)

and then of course:

dlmread('complex.txt',';')'
ans =

 (0,-0)
 (3,-4)
 (22,-0)


I think you want this:

 dlmread('complex.txt',';').'
ans =

 (0,0)
 (3,4)
 (22,0)

HTH,
Kai


[1] https://www.gnu.org/software/octave/doc/interpreter/Arithmetic-Ops.html



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: dlmread complex number - sign inverted

inor0627
siko1056 wrote
> This behavior is very expected, but fools me (this time again) often as
> well.  The '-Operator is the complex conjugate transposition [1].
> .......
> I think you want this:
>
>  dlmread('complex.txt',';').'
>
> [1]
> https://www.gnu.org/software/octave/doc/interpreter/Arithmetic-Ops.html

Hello Kai,

thank you very much for the help and explanation. I always thought, the
'-Operator just swaps the rows and columns...

Ingo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave