| Author |
Message |
aliazmat
Joined: 14 Mar 2008 Posts: 46 Helped: 2
|
04 Sep 2008 16:23 complex number matlab |
|
|
|
Hi all,
when we have some complex number like
a=0.1250 - 3.1230i and when we run command in matlab
a>=0
the result will be 1. I want to ask that how does matlab evaluates it because if we take magnitude of it by
abs(a) this comes 3.1255
so how to decide that the given complex number is great than or equal to 0?
|
|
| Back to top |
|
 |
aqua_salman
Joined: 15 Nov 2006 Posts: 139 Helped: 7 Location: Islamabad, Paksitan
|
04 Sep 2008 20:29 Re: complex number matlab |
|
|
|
matlab syntax is similar like C language.
if you want to compare the value of a, you would write if a>==0
|
|
| Back to top |
|
 |
zorro
Joined: 06 Sep 2001 Posts: 324 Helped: 36
|
04 Sep 2008 20:50 complex number matlab |
|
|
|
The correct syntax is "a>=0" without the double "==".
In the numerical comparison, the real part is taken.
Regards
Z
|
|
| Back to top |
|
 |
aliazmat
Joined: 14 Mar 2008 Posts: 46 Helped: 2
|
04 Sep 2008 22:48 Re: complex number matlab |
|
|
|
U mean that if a complex number is compared with "0" it means it is compared with only real part and imaginary part does not have any role in that
for example
0.03+9i >= 0 , answer will be 1
-0.03+9i >= 0 , answer will be 0
0.03-9i >= 0 , answer will be 1
-0.03-9i >= 0 , answer will be 0
am I right ?
|
|
| Back to top |
|
 |
zorro
Joined: 06 Sep 2001 Posts: 324 Helped: 36
|
05 Sep 2008 13:37 complex number matlab |
|
|
|
Yes, you are, aliazmat.
From Matlab help:
The relational operators are <, >, <=, >=, ==, and ~=. Relational operators perform element-by-element comparisons between two arrays. They return a logical array of the same size, with elements set to true (1) where the relation is true, and elements set to false (0) where it is not. The operators <, >, <=, and >= use only the real part of their operands for the comparison. The operators == and ~= test real and imaginary parts.
Regards
Z
|
|
| Back to top |
|
 |
xulfee
Joined: 27 May 2008 Posts: 230 Helped: 25 Location: Pakistan
|
09 Sep 2008 4:45 complex number matlab |
|
|
|
| 1 means ur statment is true
|
|
| Back to top |
|
 |
aliazmat
Joined: 14 Mar 2008 Posts: 46 Helped: 2
|
10 Sep 2008 11:05 Re: complex number matlab |
|
|
|
| thank you very very much for your help .
|
|
| Back to top |
|
 |