function untitled(a, varargin)
p = inputParser;
p.addRequired('a', @isnumeric);
p.addOptional('debug', 0, @(x)strcmpi(x, 'debug'));
p.parse(a, varargin{:})
disp(p.Results)
If i type
>> untitled(3)
a: 3
debug: 0
If i type
>> untitled(3, 'debug')
a: 3
debug: 'debug'
I want Matlab to place 1 in the debug field, i.e.
>> untitled(3, 'debug')
a: 3
debug: 1
Is it possible? Do I need to play with the anonymous function handle?
FYI, matlab doc says that if the Boolean output is true, then MATLAB
accepts the input value. I want to work around this.
Thank you.
I think you're validator is checking for the string debug rather than
validating its value.
--
Loren
http://blogs.mathworks.com/loren/
http://matlabwiki.mathworks.com/MATLAB_FAQ
Michael
"Loren Shure" <loren...@mathworks.com> wrote in message <i5g4tb$j6p$1...@fred.mathworks.com>...