[op,nread] =
read_options ( args, varargin )
¶The function read_options parses arguments to a function as, [ops,nread] = read_options (args,...) - Read options
The input being args a list of options and values. The options can be any of the following,
’op0’ , string : Space-separated names of opt taking no argument <”>
’op1’ , string : Space-separated names of opt taking one argument <”>
’extra’ , string : Name of nameless trailing arguments. <”>
’default’, struct : Struct holding default option values <none>
’prefix’ , int : If false, only accept whole opt names. Otherwise, <0> recognize opt from first chars, and choose shortest if many opts start alike.
’nocase’ , int : If set, ignore case in option names <0>
’quiet’ , int : Behavior when a non-string or unknown opt is met <0> 0 - Produce an error 1 - Return quietly (can be diagnosed by checking ’nread’)
’skipnan’, int : Ignore NaNs if there is a default value. Note : At least one of ’op0’ or ’op1’ should be specified.
The output variables are, ops : struct : Struct whose key/values are option names/values nread : int : Number of elements of args that were read
USAGE
# Define options and defaults op0 = "is_man is_plane flies" default = struct ("is_man",1, "flies",0); # Read the options s = read_options (list (all_va_args), "op0",op0,"default",default) # Create variables w/ same name as options [is_man, is_plane, flies] = getfields (s,"is_man", "is_plane", "flies") pre 2.1.39 function [op,nread] = read_options (args, ...)
Package: miscellaneous