How to use string in if else statement?
103 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
NUR SHOLIHAH RAMLEE
il 8 Giu 2018
Commentato: NUR SHOLIHAH RAMLEE
il 8 Giu 2018
hi all, i have a code that need me to use the if else statement. in my string, i have two strings of '34970A' and '3458A'. if i am using these two, the code gave me error as : matrix didnt match. how am i going to solve this?
if content_str == '34970A'
content_str = 'Apple';
else if content_str == '03458A'
content_str = 'Grape'
thank you very much for your help :)
0 Commenti
Risposta accettata
KSSV
il 8 Giu 2018
if strcmp(content_str,'34970A')
content_str = 'Apple';
else if (content_str,'03458A')
content_str = 'Grape'
end
Read about strcmp
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!