필터 지우기
필터 지우기

Call a Function in a statemachine

조회 수: 2 (최근 30일)
Svenh
Svenh 2023년 10월 27일
답변: Poorna 2023년 12월 6일
I have two reference subsystems. In the first one is my statemachine. In the second reference subsystem is another subsystem and within that is my simulink function.
I want to call that function in the statemachine in an insert state. For that i wanted to use the convetion
reference_subsystem_name.subsystem_name.function_name()
unfortunatly i receive the error message: undefined function, errors occurred during parsing of ...
I'm sure that the spelling and name is correct.
In a previous version of my model I had one subsystem less so I only had to use subsystem_name.function_name() and that worked.
Thank you for your help
  댓글 수: 2
Svenh
Svenh 2023년 10월 28일
So to further demonstrate my situation
The function block is called Heute() and is in the following subsystems:
So if the statemachine is on the same level as t2 everything works
but if the statemachine is on the same lever as "test" it doesnt work anymore
i hope this makes it more clear
Svenh
Svenh 2023년 10월 28일
and of course i adjustet the function calling in the statmachine to: test.t2.Heute()

댓글을 달려면 로그인하십시오.

답변 (1개)

Poorna
Poorna 2023년 12월 6일
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.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by