How to find required inputs from Input Parser object?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Argument Definitions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!