Switch case simple mistake
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ddd ppp
le 8 Oct 2017
Modifié(e) : Walter Roberson
le 8 Oct 2017
Hi, why doesnt 'works' show when i run this? Is it because the case has to be the switch input?
inStr='d'
switch inStr
case inStr(1)=='d'
outStr='works'
otherwise
'error'
end
0 commentaires
Réponse acceptée
Walter Roberson
le 8 Oct 2017
case inStr(1)=='d' evaluates inStr(1)=='d', generating the value false or true. That value is then compared to inStr because of switch inStr, and is found to not equal to inStr.
switch inStr(1)
case 'd'
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays 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!