Pressing a button in MATLAB app designer which changes a value of a variable in stateflow
23 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Pavan Guntha
on 19 Aug 2021
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!
0 Comments
See Also
Categories
Find more on Complex Logic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!