I want to check, whether an input is a string. Why does it not work?
p = inputParser() ;
isString = @(x) (isvector(x) | isempty(x)) & ischar(x) ;
addParameter(p, 'property_name', isString) ;
isString(13) % yields False
parse(p, 'property_name', 13) % Throws no error

 採用された回答

Matt J
Matt J 2022 年 3 月 17 日

1 投票

The validation function should be the 4th argument,
addParameter(p, 'property_name','', isString) ;

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeArgument Definitions についてさらに検索

製品

リリース

R2019b

質問済み:

2022 年 3 月 17 日

回答済み:

2022 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by