There are differences in how you can use System objects in a MATLAB System block in Simulink® versus using the same object in MATLAB®. You see these differences when working with variable-size signals and tunable parameters and when using System objects as properties.
To use variable-size signals in a System object™, you must implement propagation methods. In particular, use the
isOutputFixedSizeImpl method to specify if an output is
variable-size or fixed-size. This method is needed for interpreted execution and
code generation simulation methods.
Simulink registers public tunable properties of a System object as tunable parameters of the corresponding MATLAB System block. If a System object property is tunable, it is also tunable in the MATLAB System block. At runtime, you can change the parameter using one of the following approaches. The change applies at the top of the simulation loop.
At the MATLAB command line, use the
set_param to change
the parameter value.
In the Simulink editor, edit the MATLAB System block dialog box to change the parameter value, and then update the block diagram.
You cannot change public tunable properties from System object internal methods such as
During simulation, setting an invalid value on a tunable parameter causes an error message and stops simulation.
The MATLAB System block allows a System object to have other System objects as public or private properties. However:
System objects and other MATLAB objects stored as public properties are read only. As a result, you cannot set the value of the parameter, you can only get the value of a parameter.
System objects stored as property values appear dimmed in the MATLAB System block dialog box.
MATLAB does not require that objects assign default values to properties. However, in Simulink, if your System object has properties with no assigned default values, the associated dialog box parameter requires that the value data type be a built-in Simulink data type.
To use the MATLAB System block within a For Each Subsystem block, implement
method. This method should return
true. The MATLAB
System block clones the System object for each For Each Subsystem iteration.
In Simulink, use the
to validate only attributes (size, data type, and complexity) of the input. Do not
use this method to validate the value of the input.