MATLAB: Does the mpt.parameter not evaluate correctly in an IF-ELSE block when its datatype is anything other than a double or single in Real-Time Workshop 5.3 (R2009a)

if elsempt.parametersimulink coder

I have a model that contains an IF-ELSE Simulink block. For the logical comparison in the dialog parameter of this block I am using an mpt.parameter data object that is part of the MPT package in Real-Time Workshop Embedded Coder. I define this mpt.parameter to be of type uint16 (or any non-double, non-single) data type. When I try to update diagram or press play, I get the following error:
The expression 'u1 > Test' in 'TestIfBlockWithMPT/If' has a syntax error.

Best Answer

This is expected behavior in Real-Time Workshop 5.3 (R2009a) due to the evaluation order of the mpt.parameter at the model initialization callback. You may not evaluate variables such as uint8(5) in the IF/ELSE Simulink block as outlined in the documentation here;
To correctly evaluate the mpt.parameter object, use it in a Compare to block that feeds the IF-ELSE block and do not use a mpt.parameter in the IF-ELSE block.
See the attached original and modified models.