Are there any function to check a string in the argument list?
Mostrar comentarios más antiguos
For example, "off" is existed in the argument list or not?
2 comentarios
James Tursa
el 16 de Sept. de 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.
el 16 de Sept. de 2015
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 16 de Sept. de 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 comentarios
Mr M.
el 16 de Sept. de 2015
Image Analyst
el 17 de Sept. de 2015
If one argument is not a string, then the test will fail. All need to be strings.
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!