Input Parser and Enumerations

1 vue (au cours des 30 derniers jours)
Simon Parten
Simon Parten le 8 Oct 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

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Argument Definitions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by