Generates an error if the value of an input argument is not expected.
errmsg = fmincon_checkoption ( funname , var , varname , ivar , expectedopt )
a 1 x 1 matrix of strings, the name of the calling function.
a 1 x 1 matrix of valid Scilab data type, the variable
a 1 x 1 matrix of string, the name of the variable
a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
a n x 1 or 1 x n matrix of values, the available values for the variable #ivar
a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
This function is designed to be used to design functions where an input argument has a limited number of possible values.
// The function takes a string argument, either "r" or "c". function myfunction(x) fmincon_checkoption ( "myfunction" , x , "x" , 1 , ["r" "c"] ) disp("This is the string:" + x) endfunction // Calling sequences which work myfunction ( "r" ) myfunction ( "c" ) // Calling sequences which generate an error myfunction ( "Scilab" ) | ![]() | ![]() |