函数iptcheckinput()用于检查某个阵列是否满足相应的条件,通常用于对函数的输入阵列是否满足要求进行判定。
ipt是image process tools,即图像处理工具的缩写,MALAB里边有一个图像像处理工具箱,里边有一组函数的命名规则是在前面加上ipt
MATLAB的帮助文档对其描述如下:
iptcheckinput(A,valid_classes,valid_attributes, func_name,var_name,arg_pos) checks the validity of the input array A and issues a formatted error message if the array is invalid.
If the array has valid class and attributes as specified by valid_classes and valid_attributes, then iptcheckinput returns nothing.
If the class or attributes are invalid, then iptcheckinput issues a formatted error message that includes information about the function name (func_name), the variable name (var_name), and the argument position (arg_pos). These values are used only to create the error message, not to check whether the array is valid.
一个简单例子:
A = [ 1 2 3; 4 5 6 ];
B = [ 7 8 9; 10 11 12];
C = cat(3,A,B);
iptcheckinput(C,{'numeric'},{'2d'},'func_name','var_name',2)
由于C是由A和B组成的三维矩阵,并不满足判定条件中“2d”的要求,所以输出错误信息。
Function FUNC_NAME expected its second input, var_name, to be two-dimensional.
上面这句话中的“second”来自于其最后一个参数“2”。