strcmp: compare a string with a set of strings
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
alpedhuez
le 19 Juin 2020
Modifié(e) : alpedhuez
le 19 Juin 2020
I have a table 'test'
month temperature
---
January
February
---
I want to create a new variable called 'season'. I want to define
spring={January, February, March}
and I want to write things like
strcmp(test.month(1),spring)==1
that is, I want to use compare one string with a set of strings and to return 1 if the string is equal to one of the set of strings. Please advise.
0 commentaires
Réponse acceptée
Fangjun Jiang
le 19 Juin 2020
IsSpring=ismember('January',{'January','Feburary','March'})
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!