How to find required inputs from Input Parser object?
2 次查看(过去 30 天)
显示 更早的评论
Hi Community,
I am have implemented 'InputParser' for my MATLAB function. Here's the code snippet-
function fitElliOntoDatam_10_edit(filen,NrPlanes,makePlots)
defaultMakePlot = false;
%%%%%%% INPUT PARSER %%%%%%%%
p = inputParser;
p.FunctionName = 'fitElliOntoDatam_10_edit';
validNum = @(x) isnumeric(x) && (x > 0);
addRequired(p,'filen',@isstring);
addRequired(p,'NrPlanes',validNum);
addOptional(p,'makePlots',defaultMakePlot,@islogical);
parse(p,filen,NrPlanes,makePlots);
disp(p);
.....
......
So, when I print the inputParser object, I get the following detail -
>> fitElliOntoDatam_10_edit("export.txt",20,false)
inputParser with properties:
FunctionName: 'fitElliOntoDatam_10_edit'
CaseSensitive: 0
KeepUnmatched: 0
PartialMatching: 1
StructExpand: 1
Parameters: {'filen' 'makePlots' 'NrPlanes'}
Results: [1×1 struct]
Unmatched: [1×1 struct]
UsingDefaults: {1×0 cell}
How can I display which of these 3 parameters are 'required' or 'optional'? Where is that information stored inside inputParser object?
Also can I display the data type of these parameters from the inputParser object? Where do the validation functions get stored ?
5 个评论
回答(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!