Hi Svenh,
I understand that you are trying to call a Simulink function from inside your Stateflow chart. I also understand that you are wondering why putting Simulink function inside a subsystem at the same level as the chart works, while placing the grandparent subsystem of the Simulink function at the same level as the chart does not work.
The behaviour you are seeing is expected. The Simulink function you're using is a "scoped" function residing inside a virtual subsystem. A scoped function within a virtual subsystem can be called within the containing subsystem block hierarchy simply by using its name, like "function_name()". It can also be called from outside the subsystem but within the subsystem hierarchy by qualifying the function name with the subsystem block name, like "subsystem_name.function_name()".
Because the subsystem "subsystem_name" is not within the subsystem hierarchy of the chart (while "referenced_subsystem_name" is in the hierarchy, "subsystem_name" is not), you cannot use its Simulink function.
To still access the Simulink function, you can consider changing the scope of the Simulink function to "global". In this case, a simple call like "function_name()" should work across the model, as long as the Simulink Function is inside a virtual subsystem hierarchy.
To can find the option to change the function’s scope in the Block properties of the trigger port of the Simulink function block.
To know more about accessing Scoped Simulink function blocks in subsystems refer to the following documentation:
For an overview of different scopes of a Simulink function block, please refer to the following documentation:
Hope this Helps!
Best regards,
Poorna.