What is the difference between addOptional and addParameter in MATLAB for creating functions?
MATLAB documention of these two functions:
addOptional(p,argName,default) adds optional input, argName, to the input parser scheme of inputParser object, p. When the inputs that you are checking do not include a value for this optional input, the input parser assigns the default value to the input.
addOptional(p,argName,default,validationFcn) specifies a validation function for the input argument.
addParameter(p,paramName,default) adds parameter name and value argument paramName to the input parser scheme of inputParser object, p. When the inputs that you are checking do not include a value for this optional parameter, the input parser assigns the default value.
addParameter(p,paramName,default,validationFcn) specifies a validation function for the input argument.
addOptionalrefers to an input argument, i.e. a variable that you pass to a function. Both "functions" are in fact methods of the input parser class. Typically, you use that class within a function and pass it the function inputs you want to parse. You parse the inputs - souty