Checks that the value is lower or equal than a threshold.
errmsg=apifun_checkloweq(funname,var,varname,ivar,thr)
a 1-by-1 matrix of strings, the name of the calling function.
a matrix of values, the variable
a 1-by-1 matrix of string, the name of the variable
a 1-by-1 matrix of floating point integers, the index of the input argument in the calling sequence
a matrix of values, the maximum value for the variable #ivar
a 1-by-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 is expected to be greater or equal to a threshold. The error is generated if the condition or ( var > thr ) is true. This function can be used for whatever variable type for which the comparison ">" can be evaluated.
The arguments var and thr can be either 1-by-1 matrices (i.e. scalar) or m-by-n matrices of doubles, but not all combinations are available. The available combinations are:
The case where var is a scalar and thr is a matrix
is not available.
In this situation, please use the min
function
and the calling sequence:
errmsg=apifun_checkloweq(funname,var,varname,ivar,min(thr))
// The function takes an argument x such that x<=1. function y=myfunction(x) apifun_checkloweq ( "myfunction",x,"x",1,1 ) y = sqrt(1-x) endfunction // Calling sequences which work myfunction ( [-1.5,-2.5,-3.5] ) // Calling sequences which generate an error // myfunction ( [1.5,1] ) // myfunction ( [1,-1,2.5,0] ) | ![]() | ![]() |