How do I call Simulink function in nested subsystem?

5 views (last 30 days)
I have a Simulink function 'MyFun' in a subsystem named 'S1' which is a subsystem of 'S2'.  I am getting the following error when I call this function from the top level:
ERROR: A definition for the function 'MyFun' called by Function Caller block could not be found.
How can I call the function 'MyFun' from the function caller?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 May 2023
Edited: MathWorks Support Team on 4 May 2023
This is an expected behavior. As mentioned in the following documentation:
a function caller can be at a level where it can hierarchically resolve to the subsystem containing the function. Hence, we can only call a function from:
  1. Outside the subsystem one hierarchic level above the function
  2. In another subsystem at the same hierarchic level as the function
  3. In another subsystem one or more levels below the hierarchic level of the function
Therefore, if the function needs to be accessed at a higher hierarchy, then the function should be moved up so that the caller will be in it's hierarchy.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!