if else condition - empty vector

5 vues (au cours des 30 derniers jours)
aurc89
aurc89 le 21 Août 2014
Commenté : aurc89 le 21 Août 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

Réponse acceptée

Robert Cumming
Robert Cumming le 21 Août 2014
  1 commentaire
aurc89
aurc89 le 21 Août 2014
Thanks Robert

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by