Scoped, Global, and Port-Scoped Simulink Function Blocks Overview - MATLAB & Simulink (original) (raw)

Defining the visibility of functions can help you to avoid name space conflicts when integrating your referenced models. A Simulink Function block defines the visibility of its function in relationship to the subsystem or model containing the block as either scoped, global, or port-scoped. By default, Simulink Function blocks are scoped.

Use the Function visibility parameter for the Trigger block within a Simulink Function block to set the function visibility to either scoped, global, or port. For a port-scoped function, specify the name of the port in the Scope to port field.

Summary of Simulink Function Block Visibility and Access

Simulink Function Block Function Visibility Function Accessibility Function Exporting
Virtual Subsystem scopedFunction names at the same hierarchical level must be unique. Function caller inside hierarchy or at parent level. Function caller inside Subsystem block hierarchy – Unqualified, fcn(). See Resolve to a Function Hierarchically in Scoped Simulink Function Blocks in Subsystems.Function caller at parent level – Qualified with subsystem block name, subsystem.fcn(). See Resolve to a Function by Qualification in Scoped Simulink Function Blocks in Subsystems. Does not apply.
globalFunction name must be unique. Function caller at any level of hierarchy down or up.Function caller at any level of hierarchy – Unqualified, fcn(). Function at any level of model exported to the global name space of the top-level model.
port visibility not allowed. Does not apply. Does not apply.
Atomic Subsystem scopedFunction names at the same hierarchical level must be unique Function caller only inside hierarchyFunction caller inside Subsystem block hierarchy – Unqualified, fcn(). See Resolve to a Function Hierarchically in Scoped Simulink Function Blocks in Subsystems.Function caller at parent level – not allowed. Does not apply.
global visibility not allowed. Function call not allowed. Does not apply.
port visibility not allowed. Does not apply. Does not apply.
Model scopedFunction names must be unique at the model root level. Function caller inside hierarchy or at parent level. Function caller inside Subsystem block hierarchy – unqualified, fcn(). See Resolve to a Function Hierarchically in Scoped Simulink Function Blocks in Models.Function caller at parent level – Qualified with Model block name, model_block.fcn(). See Resolve to a Function by Qualification in Scoped Simulink Function Blocks in Models. Function at the root level of a model exported to the model interface.
globalFunction name must be unique. Function caller at any level of hierarchy down or up.Function caller at any level of hierarchy – Unqualified, fcn(). Function at any level of model exported to the global name space of the top-level model.
portFunction names at the model root level do not have to be unique if scoped to different ports. Function caller associated with invoking function port connected to exporting function port to which function is scoped. Qualified with invoking port name, PortName.fcn().For more information, see Model Client and Server Components Using Function Ports. Function not visible except through exporting function port.

See Also

Blocks

Topics