Input Parser and Enumerations

3 ビュー (過去 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 Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by