Input Parser and Enumerations

1 Ansicht (letzte 30 Tage)
Simon Parten
Simon Parten am 8 Okt. 2018
Beantwortet: Simon Parten am 8 Okt. 2018
Can anyone help me with why this might not work?
classdef WhichIlsop
enumeration
Prod()
Test()
end
end
Then when this enum is passed into a function with parameter name ilsop, I want to validate the inputs.
p = inputParser;
p.KeepUnmatched = true;
p.FunctionName = 'bah';
addRequired(p, 'ilsop', @(x) isa(x, 'WhichIlsop'));
p.parse(varargin{:});
I get this message when evaluating the 'parse' line. The other lines are the diagnostics I've done below.
The value of 'ilsop' is invalid. It must satisfy the function: @(x)isa(x,'WhichIlsop').
>> class(ilsop)
ans =
'WhichIlsop'
>> isa(ilsop, 'WhichIlsop')
ans =
logical
1

Akzeptierte Antwort

Simon Parten
Simon Parten am 8 Okt. 2018
Bah ... p.parse(ilsop, varargin{:});

Weitere Antworten (0)

Kategorien

Mehr zu Argument Definitions finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by