Trouble using strings in If statements using OR
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to loop through and use IF statement as example:
if race == "H2" | "H1" | "H3" | "H4"
but I get error "Error using |
Input must be text or pattern."
If I try: race == "H2" || "H1" || "H3" || "H4"
I get error:
Conversion to logical from string is not possible.
"H1" and so forth are strings in Matlab
Thank you!
Risposta accettata
Voss
il 20 Gen 2022
if race == "H2" || race == "H1" || race == "H3" || race == "H4"
1 Commento
Walter Roberson
il 20 Gen 2022
Or alternately
if ismember(race, ["H1", "H2", "H3", "H4"])
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!