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 or global. By default, Simulink Function blocks are scoped.
Function Visibility. A scoped function is visible in its hierarchy. A function caller located at the same level as the function, or one or more levels below can refer to the function. A global function is visible across a model hierarchy. This means that a function caller located anywhere in the current model or in the parent model hierarchy can refer to the function.
Function accessibility is determined by the visibility of a function and the location of the function caller relative to the Simulink Function block. For function callers one hierarchical level above the function, qualify the function name with the virtual subsystem block name or model block name.
Function exporting refers to functions exported from models. A function with global visibility, placed anywhere in an export function model, is exported to the top level of a model hierarchy in addition to the model interface. A function with scoped visibility at the root level of an export function model is exported to the model interface. In both these cases, you can access the exported function outside of the model.
Use the Function visibility parameter for the Trigger
block within a Simulink Function block to set the function visibility to either
scoped
or global
.
Summary of Simulink Function Block Visibility and Access
Function visibility | Function accessibility | Function exporting | |
---|---|---|---|
Virtual Subsystem |
Function name does not have to be unique | function caller inside hierarchy or at parent level. function
caller inside Subsystem block hierarchy – unqualified, function caller at parent level – qualified with subsystem block
name, | Does not apply |
Function name must be unique | function caller at any level of hierarchy down or up. function
caller at any level of hierarchy – unqualified,
| Function at any level of model exported to the global name space of the top-level model | |
Atomic Subsystem |
Function name does not have to be unique | function caller only inside hierarchy function caller inside
Subsystem block hierarchy – unqualified, function caller at parent level – not allowed | Does not apply |
| function call not allowed | Does not apply | |
Model |
Function name does not have to be unique | function caller inside hierarchy or at parent level. function
caller inside Subsystem block hierarchy – unqualified, function caller at parent level - qualified with Model block name,
| Function at the root level of a model exported to the model interface |
Function name must be unique | function caller at any level of hierarchy down or up. function
caller at any level of hierarchy – unqualified,
| Function at any level of model exported to the global name space of the top-level model |