Using different data types for a 3D Table

The input parameters to a PLECS Blockset model should be double precision, which is the default numeric type in Matlab. As you suggested, the Data Type block is one solution to convert to the desired data format within the PLECS model. A simple function could be used to determine the data type of the input variable and automatically determine the appropriate setting for the Data Type block, when available.

There is no built-in conversion to the half precision datatype. One option would be to cast to the desired type in a C-script. There is some nuance here, as the compiler used only supports the ‘__fp16’ conversion (storage data type and not arithmetic) and the all outputs of C-Scripts are re-cast to doubles. If you are using the output of this block for further manipulation you should be aware of these limitations.

A simple demo is attached showing these basic approaches is attached. Run the “datatypes.m” file to compare the results between the Matlab workspace and PLECS/Simulink.

datatypes.m (643 Bytes)

simdatatypes.slx (28.4 KB)