Are there any function to check a string in the argument list?
10 views (last 30 days)
Show older comments
For example, "off" is existed in the argument list or not?
2 Comments
James Tursa
on 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'?
Accepted Answer
More Answers (1)
Image Analyst
on 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 Comments
Image Analyst
on 17 Sep 2015
If one argument is not a string, then the test will fail. All need to be strings.
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!