MATLAB: Can I specify the output of the Compare to Constant block to be a data type other than boolean or uint8

compareconstantdatasimulinktotypezero

I want to specify the output of the Compare to Constant block to be a data type other than boolean or uint8.

Best Answer

The ability to specify the output of Compare to Constant and Compare to Zero blocks to be a data type other than boolean or uint8 is not available in Simulink.
To work around this issue, either use the Relational Operator block (which allows any Simulink data type to be specified for its output), or pass the output into a Data Type Conversion block.
Alternatively, the block in the library is a masked subsystem and could easily be modified to provide additional output options by making changes to the mask initialization code. If you maintain your own custom blocks library, the block can be added to the custom library and the relevant changes to handling the output data type can be made to the block in the custom library.