How to use logical "OR" operation for comparing string??
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I tried with the code as given:
strcmp('normal'||'neptune',{'normal'; 'DoS'; 'neptune'; 'R2L'})
and the error is saying that the OR "||" operator must be convertible to logical scalar values. So, what could be the possible solution to this?? thanks in advance.
0 commentaires
Réponse acceptée
Walter Roberson
le 15 Déc 2017
any( ismember({'normal', 'neptune'}, {'normal'; 'DoS'; 'neptune'; 'R2L'}) )
4 commentaires
Walter Roberson
le 15 Déc 2017
For the index positions,
[tf, idx] = ismember({'normal', 'neptune'}, {'normal'; 'DoS'; 'neptune'; 'R2L'})
The returned idx would be [1 3] in this example.
idx(K) will be valid only in the locations where tf(K) is true (and will be 0 otherwise.)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Formula Manipulation and Simplification 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!