Validate That Argument Has Specified Underlying Type
UsemustBeUnderlyingTypeto validate that the input has underlying typedouble。
Create adistributedarray (requires Parallel Computing Toolbox™) and then validate that the underlying data type isdouble。
x = distributed(single(1:10)); mustBeUnderlyingType(x,"double")
使用“本地”配置文件启动并行池(Parpool)连接到并行池(工人数:6)。
Value must have underlying type 'double'.
mustBeUnderlyingTypethrows an error because the underlying type of the distributed array issingle。
Restrict Function Argument Values
UsemustBeUnderlyingTypeto restrict the input argument values that are accepted by a function. You can accomplish this by adding an争论block to the function that validates the input arguments.
This function declares one input argument. In the争论block, the input is required to have an underlying data type ofsingle。
functiony = mbSingle(input)争论input{mustBeUnderlyingType(input,"single")}enddisp("Input is class "+类(输入)+。.." with underlying type "+ underlyingType(input) +".")end
Call the function with adistributedvector (requires Parallel Computing Toolbox) that has underlying data of typesingle。Since the input passes the argument validation, thembSinglefunction prints information about the class and underlying type.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.