Input Parser and Enumerations

조회 수: 1 (최근 30일)
Simon Parten
Simon Parten 2018년 10월 8일
답변: Simon Parten 2018년 10월 8일
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

채택된 답변

Simon Parten
Simon Parten 2018년 10월 8일
Bah ... p.parse(ilsop, varargin{:});

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by