|
"Muhammad " <muhali@shaw.ca> wrote in message
news:hcfjrm$jcs$1@fred.mathworks.com...
> Complex number are ordered in matlab. For the imaginary unit, i, for
> example, I get
> ? disp(i < 0 | i == 0)
> ans =
> 0
> This may be consistent behavior. But it is certainly inconsistent with the
> following result:
> ? disp (i <= 0)
> ans =
> 1
Ordering where complex numbers are involved should be based on the real
parts. If 2 complex numbers have the same real part, then the imaginary part
(its absolute value) should break the tie.
In the first example, i<0 , here since real part of i which is 0 is NOT
less than zero then i<0 is false. For i==0, since the real parts are equal
(both are zero) then we look at the imaginary part to break the tie. Since
the abs value of the imaginary part of i (which is 1) is clearly not equal
to the imaginary part of zero, which is zero, then we get False again.
Hence the result false Or False is False as shown.
For the case of i<=0, the real part of i is zero, and the real part of 0 is
zero, so it is a tie, looking at the imaginary parts, the absolute value of
the imaginary part of i is 1, and the for 0 it is zero, hence 1<=0 should be
False.
Hence Matlab answer for i<=0 should be 0 not 1. This is a bug. Or Matlab
uses some other logic to decide on these issues.
--Nasser
|