How to find required inputs from Input Parser object?
조회 수: 4 (최근 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!