Generates an error if the given variable is not of expected type.
errmsg = fmincon_checktype ( funname , var , varname , ivar , expectedtype )
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 strings, the available types 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 with input arguments with variable type. We use the typeof function to compute the type of the variable: see help typeof to get the list of all available values for expectedtype. Last update : 29/07/2010.
// The function takes a string argument. function myfunction(x) fmincon_checktype ( "myfunction" , x , "x" , 1 , "string" ) disp("This is a string") endfunction // Calling sequences which work myfunction ( "Scilab" ) // Calling sequences which generate an error myfunction ( 123456 ) // The function takes a string or a matrix of doubles argument. function myfunction(x) fmincon_checktype ( "myfunction" , x , "x" , 1 , [ "string" "constant" ] ) if ( typeof(x) == "string" ) then disp("This is a matrix of strings") else disp("This is a matrix of doubles") end endfunction // Calling sequences which work myfunction ( "Scilab" ) myfunction ( 123456 ) // Calling sequences which generate an error myfunction ( uint8(2) )