This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Scoped and Global Simulink Function Blocks Overview

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 visibilityFunction accessibilityFunction exporting
Virtual Subsystem

scoped

Function name does not have to 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

global

Function 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

Atomic Subsystem

scoped

Function name does not have to be unique

function caller only inside hierarchy

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 – not allowed

Does not apply

global visibility not allowed

function call not allowed

Does not apply

Model

scoped

Function name does not have to 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 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

global

Function 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

Summary of Simulink Function Block Visibility and Access

See Also

Blocks

Related Topics