Pressing a button in MATLAB app designer which changes a value of a variable in stateflow
64 views (last 30 days)
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:
app.compLogic = mylogic('app', app);
Then in the callback for the button:
function ButtonPushed(app, event)
app.keyrequest = 1;
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!
Pavan Guntha on 19 Aug 2021
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!