Input Parser and Enumerations

1 visualizzazione (ultimi 30 giorni)
Simon Parten
Simon Parten il 8 Ott 2018
Risposto: Simon Parten il 8 Ott 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

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Argument Definitions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by