@
@
@xave2013-09-25 15:56:03
MATLAB
@xave, 2013-09-25 15:56:03

What does the given line of MATLAB code do?

I came across a very interesting piece of code here:

a = b < c < b;

I don't understand the meaning of this magic. The variable a contains the result of the comparison, i.e. 0 or 1. For example, a = 0 for 0 < 4 < 0, but at the same time a = 1 for 2 < 4 < 2.
Can anyone explain what's going on here? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eddy_Em, 2013-09-25
_

Here the implicit order of evaluation is used: (b < c) < b, i.e. this expression will give 1 if b>=c & b>0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question