Pressing a button in MATLAB app designer which changes a value of a variable in stateflow

조회 수: 36 (최근 30일)
Hello, so I am trying to press a button and when the callback for the button pushed is called, the program should change the value of a variable in the stateflow diagram. In order to do this, I have done the following:
In the startup function I have used the following line of code which links the stateflow chart to the app designer:
function startupFcn(app)
app.compLogic = mylogic('app', app);
end
Then in the callback for the button:
function ButtonPushed(app, event)
app.keyrequest = 1;
end
The variable keyrequest is a variable in the stateflow diagram, and by setting the value of this variable to something other than 0, the state machine starts to operate. I have tried to add the keyrequest as a property, but it still wasn't working. I feel like I need to use compLogic thing, but I don't really know how.
Any help would be much appreciated.
Thank you in advance!

답변 (1개)

Pavan Guntha
Pavan Guntha 2021년 8월 19일
Hello Tb,
I understand that the issue here is with changing the data within stateflow by an action made through app (like button clicks). You could make use of events in stateflow which can easily be integrated with the components in app designer through callbacks. You could have a look at the attached files to understand a simple example which illustrates how we can control a state transfer through a button click. For more details, you could have a look at the example illustrated in the following page:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by