inputParser does not throw error
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Matt J
2022-3-17
The validation function should be the 4th argument,
addParameter(p, 'property_name','', isString) ;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!