Resolve Error: Block Is Unable to Call The Scoped Simulink Function
Issue
The scoped Simulink® function must be accessible by the caller. The accessibility of a function is determined by the visibility and location of the function caller relative to the Simulink Function block. For more information on function visibility and accessibility, see Scoped, Global, and Port-Scoped Simulink Function Blocks Overview.
If the function caller is unable to access the function definition and the caller has a scope name specified, the software might produce this error.
Block is unable to call the function with scope name because the function definition is not found
.
If a scope name is not specified in the caller, the software might not produce an error during compilation or code generation, because the function may be defined externally as a global function. However, the simulation always gives an error if the function is not resolved. For the Function Caller block, the software produces this error.
A definition for the function called by Function Caller block could not be found
.
Possible Solutions
This error message occurs when the function caller is unable to access the function definition. To ensure that the function is accessible by the caller, use hierarchical guidelines depending on the configuration of your model.
Call Function Inside Model
The Simulink Function block or its parent subsystem must be placed at the same or higher hierarchical level of the caller block.
If the Simulink Function block is placed at the same or higher hierarchical level as the caller block, the caller can call the function name directly.
If the parent subsystem of the Simulink Function block is placed at the same or higher hierarchical level than the caller block, the caller must use the subsystem name as the scope name to qualify the function.
For more information, see Resolve to a Function by Qualification.
For an example, see Monitor Ink Status on Shared Printer Using Simulink Functions or Dynamic Priority Scheduling of Functions.
Call Function from Reference Model
When the Simulink function is defined in a reference model, the corresponding Model block must be placed at the same or higher hierarchical level of the caller block in the caller model. The reference model containing the Simulink function must be an export-function model.
The caller must use the name of the Model block as the scope name to qualify the function. The name of the Model block is the instance name, so it supports multiple instances.
For more information, see Resolve to a Function by Qualification.
Call Function from Separate Model
A Simulink function can also be defined in a separate export-function model that is not referenced in the caller model. This separate export-function model must be on the MATLAB® path and must have a unique name.
The caller must use the model file name as the scope name to qualify the function. Only a single instance of the function model is allowed because the caller does not specify an instance.
You can simulate this scenario by having a parent model that references the model with the function model and the model with the caller.
For more information, see Function and Function Caller Blocks in Separate Referenced Models.
For an example, see Model Service Access from Application Software Using Scoped Simulink Functions.