This will not do, what you expect. Matlab processes this expression from left to right:
- 1 < abc. This is either TRUE or FALSE, which is interpreted as 1 or 0
- 1 <= 5 or 0 <= 5. This is TRUE in both cases.
Then your if and elseif will work.
For productive code using logical indexing as suggested by Birdman is usually more efficient and nicer. But understanding why a<b<c fails is essential.