Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: 3 condition in IF statement
Replies: 16   Last Post: Aug 1, 2013 12:52 PM

 Messages: [ Previous | Next ]
 Loren Shure Posts: 1,061 Registered: 12/7/04
Re: 3 condition in IF statement
Posted: Aug 1, 2013 8:31 AM

"Babak " <b_mn@hotmail.com> wrote in message
news:kt9ee8\$bt7\$1@newscl01ah.mathworks.com...
> "Roger Stafford" wrote in message
> <kt9dkd\$a5l\$1@newscl01ah.mathworks.com>...

>> "Babak " <b_mn@hotmail.com> wrote in message
>> <kt96mq\$m84\$1@newscl01ah.mathworks.com>...

>> > > > if ((0>=f1<=2) && (4>=f2<=5) && (1>=THD<=6))
>> - - - - - - -
>> 'Someone' is right. Strictly speaking, that notation is allowed, but
>> it is interpreted in the following remarkable way. In "4>=f2<=5" suppose
>> f2 = 6. Then the expression is parsed as:
>>
>> (4>=f2)<=5
>>
>> The "4>=f2" portion would be false which gives "false<=5", but since the
>> "<=" demands numerical values at either end, the 'false' is translated to
>> a numerical 0, which gives "0<=5" and that is actually true. However
>> this is certainly not what one would expect in such a case.
>>
>> Many people have been tripped up by this kind of unintended result.
>> The obvious remedy is to never, never use expressions of a form similar
>> to a<=b<=c in matlab.
>>
>> Roger Stafford

>
> Very interesting! Thank you for more info,nowhere I could find such info

--
--Loren

http://blogs.mathworks.com/loren

Date Subject Author
7/30/13 Babak
7/30/13 Roger Stafford
7/30/13 Babak
7/30/13 Curious
7/30/13 Roger Stafford
7/30/13 Babak
7/30/13 dpb
8/1/13 Loren Shure
8/1/13 Curious
8/1/13 dpb
7/30/13 dpb
7/30/13 Roger Stafford
7/31/13 dpb
7/30/13 Nasser Abbasi
7/30/13 dpb
7/31/13 dpb
7/31/13 Marc