<< Check size Check size apifun_checkscalar >>

Apifun >> Apifun > Check size > apifun_checkdims

apifun_checkdims

Generates an error if the variable has not the required size.

Calling Sequence

errmsg=apifun_checkdims(funname,var,varname,ivar,matdims)

Parameters

funname :

a 1-by-1 matrix of strings, the name of the calling function.

var :

a 1-by-1 matrix of valid Scilab data type, the variable

varname :

a 1-by-1 matrix of string, the name of the variable

ivar :

a 1-by-1 matrix of floating point integers, the index of the input argument in the calling sequence

matdims :

1 x 2 matrix of floating point integers, the number of rows, columns for the variable #ivar

errmsg :

a 1-by-1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.

Description

This function is designed to be used to design functions where the input argument has a known shape. This function cannot be use when var is a function, or more generally, for any input argument for which the size function does not work.

We recommend to check the type, and then the size (and not the other way). Indeed, if the type of the argument is not good, the size function may not be callable for the given argument.

Last update : 05/08/2010.

Examples

// The function takes a 2 x 3 matrix of doubles.
function y=myfunction(x)
apifun_checkdims ( "myfunction",x,"x",1,[2 3] )
y = x
endfunction
// Calling sequences which work
y = myfunction ( ones(2,3) )
y = myfunction ( zeros(2,3) )
// Calling sequences which generate an error
y = myfunction ( ones(1,3) )
y = myfunction ( zeros(2,4) )

Authors


<< Check size Check size apifun_checkscalar >>