Filter löschen
Filter löschen

Switch case simple mistake

1 Ansicht (letzte 30 Tage)
ddd ppp
ddd ppp am 8 Okt. 2017
Bearbeitet: Walter Roberson am 8 Okt. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Okt. 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'

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by