if else condition - empty vector

5 views (last 30 days)
aurc89
aurc89 on 21 Aug 2014
Commented: aurc89 on 21 Aug 2014
Hello, I have a doubt on this code:
x = []
if x == []
a=3
else
a=4
end
I don't understand why it always returns a = 4, even if x is an empty vector. How shall I modify it to obtain a right condition on x ? Thanks

Accepted Answer

Robert Cumming
Robert Cumming on 21 Aug 2014
help isempty

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!