Class: matlab.System

Register Simulink function names used in your System object


names = getSimulinkFunctionNamesImpl(obj)


names = getSimulinkFunctionNamesImpl(obj) specifies the Simulink® function names used in the System object™ obj.

If you use a Simulink function in your System object, you can only call a Simulink function from the stepImpl, updateImpl, or outputImpl method.

Run-Time Details

getSimulinkFunctionNamesImpl is invoked by the MATLAB System during model compilation to obtain the list of Simulink functions being called from the System object. Simulink uses this information to resolve the function names to a Simulink function declared in a Simulink Function block. If getSimulinkFunctionNamesImpl does not return the name of a function being called in the System object methods, Simulink attempts to resolve the function to a function on the MATLAB path.

Method Authoring Tips

You must set Access = protected for this method.

Input Arguments

expand all

System object handle used to access properties, states, and methods specific to the object. If your getSimulinkFunctionNamesImpl method does not use the object, you can replace this input with ~.

Output Arguments

expand all

The names of the Simulink function you want to call from your System object.


expand all

Register three Simulink functions that you want to call from your System object. The Simulink function names must match the name registered in the Simulink Function block.

methods (Access = protected)
  function names = getSimulinkFunctionNamesImpl(obj)
    names = ["setPosition", "doProcessing", "timesTwo"];

This example shows two Simulink Functions conditionally called by a MATLAB System block using the nontunable properties of the System object®.

The MATLAB System block calls one of the Simulink Functions inside two different subsystems, depending on the value of the signal coming from the Sine Wave block. If the value of the signal is less than 10, the MATLAB System block calls the timestwo_func Simulink Function inside the SS1 Subsystem block. If the value is larger than 10, it calls the timesthree_func in the SS2 Subsystem block.

Function names are defined as nontunable properties, are switched from string to functions using the str2func function. Then, these functions are declared as properties in the getSimulinkFunctionNamesImpl method.

Introduced in R2019a