Right here is an animation with annotations that can assist you getting began along with your first sport:
Acknowledgements
Earlier than going into the main points of the curling app model 2022, I need to acknowledge a number of colleagues who labored on these updates. As I discussed above, this curling simulator has a comparatively lengthy historical past, and MathWorkers like making an attempt out new options with it.
Karthiga, Michael, Robyn, Ying, Sarah, and Corey
Linking App Designer, Stateflow for MATLAB and Simulink
When you take a look at the startupFcn callback of the app, the very first thing it does is instantiate the Stateflow chart and go to it a deal with to the app itself. That is the important thing for the bi-directional linking between the app and the chart.
In a single course, within the app callbacks, this enables me to set off occasions outlined within the Stateflow chart. Within the different course, the Stateflow chart can entry and management widgets within the app:
Simulink Compiler
Since R2020b, Simulink Compiler launched new features to set callbacks to get information out and in of the simulation whereas it’s operating:
Here’s what the code creating the Simulink.SimulationInput object handed to the sim command appears to be like like:
In a means just like how we linked the app and the Stateflow chart, a deal with to the app is handed to the callbacks. That means, the callbacks can entry and management the app widgets. For instance, right here is the chain of occasions for the InputFcn callback:
- The consumer clicks the Sweep button within the app
- The sweep button callback triggers the sweep occasion within the Staflow chart
- The sweep occasion adjustments the worth of the “sweepVal” property outlined within the Stateflow chart
- When the simulation triggers the inputFcn callback, it reads the worth of app.curl.sweepVal
- The Inport block sweepInput outputs the worth of app.curl.sweepVal learn within the inputFcn callback.
3D Visualization
One other enhancement you in all probability seen in comparison with the earlier model is the addition of a 3D visualization.