Validate That Argument Has Specified Underlying Type
Use mustBeUnderlyingType to validate that the
input has underlying type double.
Create a distributed array (requires Parallel Computing Toolbox™) and then validate that the underlying data type is
double.
x = distributed(single(1:10));
mustBeUnderlyingType(x,"double")
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 6).
Value must have underlying type 'double'.
mustBeUnderlyingType throws an error because the underlying
type of the distributed array is single.
Restrict Function Argument Values
Use mustBeUnderlyingType to restrict the input
argument values that are accepted by a function. You can accomplish this by adding an
arguments block to the function that validates the input
arguments.
This function declares one input argument. In the arguments
block, the input is required to have an underlying data type of
single.
function y = mbSingle(input)
arguments
input {mustBeUnderlyingType(input,"single")}end
disp("Input is class " + class(input) + ..." with underlying type " + underlyingType(input) + ".")
end
Call the function with a distributed vector (requires Parallel Computing Toolbox) that has underlying data of type single. Since the
input passes the argument validation, the mbSingle function prints
information about the class and underlying type.
x = distributed(single(1:10));
mbSingle(x)
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 6).
Input is class distributed with underlying type single.
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.