MATLAB: Are Simulink.Signal objects’ Max and Min not enforced in the generated code


I have a model where several signals are associated with a "Simulink.Signal" object. These objects have a specified "Max" and "Min" parameter. However, I do not see these limits enforced in the generated code. Why is it that these limits appear to be arbitrary?

Best Answer

  • Currently, the "Max" and "Min" properties of "Simulink.Signal" objects have no effect on the generated code. These parameters are meant for simulation range checking only, as described in the following documentation:
    With the "Simulation range checking" diagnostic set to "warning" or "error", Simulink will notify you when the selected signal exceeds the range set by the Minimum and Maximum parameters of the corresponding "Simulink.Signal" object.
    In order to conduct a form of range checking in the generated code, one approach is to include a "Saturation" block. This block will effectively limit the signal between the specified saturation values.