The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Loren Shure

Posts: 1,067
Registered: 12/7/04
Re: 3 condition in IF statement
Posted: Aug 1, 2013 8:31 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Babak " <> wrote in message
> "Roger Stafford" wrote in message
> <kt9dkd$a5l$>...

>> "Babak " <> wrote in message
>> <kt96mq$m84$>...

>> > > > 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

I wrote about this on my blog last year:


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.