randoo
randoo

Reputation: 37

Octave inputParser.addRequired is undefined

I have updated my Octave from version 3.8.2 to 4.4.1, now one part of a code doesn't work as before, and I don't even understand what this lines should be good for.

The problem occurs at the beginning of a function witch gets a year and returns 0, 1 weather it's a leap year or not.

 22 p = inputParser;
 23 p = p.addRequired('Year',@(x) all(isnumeric(x)));
 24 p = p.parse(Year);

The error I get is:

error: value on right hand side of assignment is undefined
error: called from
    leapyear at line 23 column 3

So why there is this inputParser at all? And how can I get it to work in the new Octave version?

Unfortunately there is no documentation for the inputParser function:

octave:23> help(inputParser)
error: help: invalid input

Upvotes: 0

Views: 88

Answers (1)

Cris Luengo
Cris Luengo

Reputation: 60660

I cannot guess as to why that code worked in Octave 3.8, the oldest documentation for Octave available online is for version 4.0.

The Octave 4.4 documentation specifies that inputParser.addRequired() doesn't have an output value. So change line 23 by removing p =, so that it reads:

p.addRequired('Year',@(x) all(isnumeric(x)));

Note that MATLAB's documentation for inputParser says the same thing.

Upvotes: 3

Related Questions