octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #52420] inputParser optional argument is "not


From: Rik
Subject: [Octave-bug-tracker] [bug #52420] inputParser optional argument is "not a valid parameter"
Date: Thu, 16 Nov 2017 20:09:03 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Update of bug #52420 (project octave):

                  Status:               Confirmed => Need Info              

    _______________________________________________________

Follow-up Comment #2:

Can the original reporter test this code, as written, in Matlab?  I'm not
certain that it is valid.  According to the documentation for addOptional
(http://www.mathworks.com/help/matlab/ref/inputparser.addoptional.html),
addOptional creates a positional input variable, not a key/value pair.


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.

Use addOptional to add an individual argument into the input parser scheme. If
you want to parse an optional name-value pair, use the addParameter function.


If you want to call with syntax of "name", value then you need to use
addParameter.  Making that change to foo allows the function to run
correctly.


function foo(a, varargin)
    p = inputParser();
    addParameter(p, 'sigma', 0, @isnumeric);
    parse(p, varargin{:});
    p.Results.sigma
end




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?52420>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]