Categories &

Functions List

Function Reference: parsePairedArguments

datatypes: [optarg_1, …, optarg_N] = parsePairedArguments (optarg_names, default_values, arg_list)
datatypes: [optarg_1, …, optarg_N, rem_args] = parsePairedArguments (optarg_names, default_values, arg_list)

Parse optional paired arguments from variable argument list.

parsePairedArguments parses the optional paired arguments specified by optarg_names from the variable input argument list, arg_list. Any optarg_names that are not found in arg_list are returned with their default value specified by default_values, which must be a cell array with the same number of elements as optarg_names.

optarg_names must be a cell array of character vectors or a string array with the same number of elements as the number of output arguments specified as [optarg_1, …, optarg_N], while an extra output argument, rem_args, may be specified for the remaining input arguments in arg_list that were not specified by optarg_names.

Each property name specified by optarg_names is case insensitive.

The following example illustrates how to use parsePairedArguments inside a function to parse optional paired arguments for three properties, namely 'A', 'B', and 'C'.

 
 ## Declare optional property Names and their default Values
 optNames = {'A', 'B', 'C'};
 dfValues = {1, 2, 3};

 ## Parse optional Name-Value paired arguments
 [var_A, var_B, var_C, args] = parsePairedArguments (optNames, dfValues, args);
 

Source Code: parsePairedArguments