Call a Simulink Function from a Callback Button

조회 수: 3 (최근 30일)
Thomas Kotwal
Thomas Kotwal 2019년 8월 28일
댓글: Fangjun Jiang 2023년 1월 18일
I have defined a Simulink Function in one subsystem with Function Visibility set to global. I verified this works by calling it from a Stateflow chart in a different subsystem.
I have a Callback Button dashboard control that I would like to use to call the Simulink Function. But when I run the simulation and click on the button, I get an error saying that the function doesn't exist. My guess is that it is possible, but I'm not calling it appropriately. The button is in the same subsystem as the Stateflow chart I used to call the Simuilnk Function.
The function is called txCommand(cmd).
In the Callback Button, I have the ClickFcn callback set to:
txCommand(51);
Is there particular syntax required to tell the Callback Button where to find the Simulink Function?
Thank you.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2019년 8월 29일
I would think this is not possible. The callback function of the button needs to be MATLAB based. In other words, if the function can be called at the MATLAB Command line, then it can be called by the button callback. A Simulink function can not be called or executed at the MATLAB Command line.
  댓글 수: 3
Shiv Nileshkumar Matliwala
Shiv Nileshkumar Matliwala 2023년 1월 18일
Can anyone tell me how can I change the Button Text parameters using Matlab command like set_param() function ?
Fangjun Jiang
Fangjun Jiang 2023년 1월 18일
h=uibutton;
set(h,'Text','MyButton')

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

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by