Main Content

Considerations for Using System Objects in金宝app

There are differences in how you can use System objects in aMATLAB System集团k 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.

Variable-Size Signals

To use variable-size signals in a System object™, you must implement propagation methods. In particular, use theisOutputFixedSizeImplmethod to specify if an output is variable-size or fixed-size. This method is needed for interpreted execution and code generation simulation methods.

Tunable Parameters

Simulink registers public tunable properties of a System object as tunable parameters of the correspondingMATLAB System集团k. If a System object property is tunable, it is also tunable in theMATLAB System集团k. 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 theset_paramto change the parameter value.

  • In the Simulink editor, edit theMATLAB System集团k 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 asstepImpl.

During simulation, setting an invalid value on a tunable parameter causes an error message and stops simulation.

System Objects as Properties

TheMATLAB System集团k 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 theMATLAB System集团k dialog box.

默认属性Values

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.

System Objects in For Each Subsystems

To use the MATLAB System block within aFor Each Subsystem集团k, implement thesupportsMultipleInstanceImplmethod. This method should returntrue. TheMATLAB System集团k clones the System object for eachFor Each Subsystemiteration.

Input Validation

In Simulink, use thevalidateInputsImplmethod to validate only attributes (size, data type, and complexity) of the input. Do not use this method to validate the value of the input.

See Also

Related Examples

More About