You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The inputParser.addOptional method is being used for the optional arguments. addOptional is meant for positional arguments, i.e., arguments that are interpreted based on their position of the argument list. From mathworks documentation:
Arguments added to the input parser scheme with the addOptional function are positional. Therefore, add them to the input parser scheme in the same order they are passed into the function.
However, all examples show them being used as named parameters and out of order:
mdDelay(data, 'maxLag', 25, 'plottype', 'all');
I have tested it in Matlab and indeed it works. However, it is weird because not only the options are out of order (the options order is plottype, numBins, maxLag,...) but also because the option names seem to be ignored. Reading the documentation, one would expect that the above call would result in the following:
I don't understand how this is working in Matlab, but it would be clearer if addParameter was used instead:
Use addOptional to add an individual argument into the input parser scheme. If you want to parse an optional name-value pair, then use the addParameter function.
The reason to request this change is so that this code can also be used in Octave.
The text was updated successfully, but these errors were encountered:
I will look into this. From your description it seems that using addParameter instead would be the correct way of dealing with the arguments. I've probably been influenced by how arguments are handled in JavaScript and Python and not read the MATLAB documentation properly.
I've added this to my to-do list and will look into it ASAP.
The
inputParser.addOptional
method is being used for the optional arguments.addOptional
is meant for positional arguments, i.e., arguments that are interpreted based on their position of the argument list. From mathworks documentation:However, all examples show them being used as named parameters and out of order:
I have tested it in Matlab and indeed it works. However, it is weird because not only the options are out of order (the options order is plottype, numBins, maxLag,...) but also because the option names seem to be ignored. Reading the documentation, one would expect that the above call would result in the following:
I don't understand how this is working in Matlab, but it would be clearer if
addParameter
was used instead:The reason to request this change is so that this code can also be used in Octave.
The text was updated successfully, but these errors were encountered: