Are there any function to check a string in the argument list?
Afficher commentaires plus anciens
For example, "off" is existed in the argument list or not?
2 commentaires
James Tursa
le 16 Sep 2015
Do you mean, is any argument in the function equal to a string 'off'? Or do you mean how to check if a particular argument was actually passed in and is equal to the string 'off'?
Mr M.
le 16 Sep 2015
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 16 Sep 2015
See this snippet:
ca = {'fubar', 'snafu', 'foobar', 'Off', 'off', 'office'}
% Case sensitive search
[ia, ib] = ismember(ca, 'off')
% Case insensitive search
[ia, ib] = ismember(lower(ca), 'off')
For you, the cell array ca would be "vargin" cell array.
2 commentaires
Mr M.
le 16 Sep 2015
Image Analyst
le 17 Sep 2015
If one argument is not a string, then the test will fail. All need to be strings.
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!