select string by condition
Afficher commentaires plus anciens
if i want select value by condition i can write
(a==1)*3+(a~=1)*5
when a will get 3 if a is 1 or 5 if not.
can i do somthing like this but the result is a string. foe example:
(a==1)*'Good'+(a~=1)*'bad'
when a will be 1 i will get 'good' else i will get 'bed'
i want it for sprintf. i want write a message that if a value is lower from 0 it will write 'loss' and if it higher it write 'profit'
sprintf('Are %s is %d', (v<0)loss (v>0)profit, v)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!