if else condition - empty vector

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

 採用された回答

Robert Cumming
Robert Cumming 2014 年 8 月 21 日

0 投票

help isempty

1 件のコメント

aurc89
aurc89 2014 年 8 月 21 日
Thanks Robert

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2014 年 8 月 21 日

コメント済み:

2014 年 8 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by