为了
2022年冬季奥运会
, I am excited to share a new version of the
Simulink Curling Simulator
! This is now the third Winter Olympics that our curling game is participating in, making it something of a Simulink tradition. For those not familiar with this app, you can see how it evolved over the years in these posts:
免责声明:
我真的很想在此博客文章中包括一个链接到一个公开可用的网络应用程序,供大家在您的网络浏览器中尝试游戏,就像我们去年为The Whe Web浏览器中的游戏
指数病毒扩散模拟器
, but I ran into a technical issue. We are still investigating that; I will update the post once the web app is available.
这是一个带有注释的动画,可帮助您开始第一场游戏:
致谢
在探讨Curling App版本2022的详细信息之前,我要感谢几位研究这些更新的同事。正如我上面提到的那样,这个冰壶模拟器具有相对较长的历史,而数学工作者喜欢尝试使用新功能。
Karthiga,Michael,Robyn,Ying,Sarah和Corey
链接应用程序设计器,MATLAB和SIMULINK的状态流金宝app
One of the important things to realize with the curling app is that the app graphical elements are defined in App Designer, but most of the app logic is defined in a
状态流chart executed as a MATLAB object
。我喜欢这种做事的方式,因为状态流语言非常方便地表达应用程序所需的逻辑。
如果您查看该应用程序的启动FCN回调,则它要做的第一件事就是实例化状态图并将其传递给应用程序本身的句柄。这是应用程序和图表之间双向链接的关键。
在一个方向上,在应用程序回调中,这使我能够触发状态流图中定义的事件。在另一个方向上,状态流图可以在应用程序中访问和控制小部件:
Simulink Compiler
此版本的Curling应用程序是我尝试使用Simulink编译器作为Web应用程序部署的第二个应用程序。金宝app最后一次是在2020年,
病毒传播模拟器
。At this time, in R2020a, I could only call the
sim
完成仿真后,命令并为结果动画。
Since R2020b, Simulink Compiler introduced new functions to set callbacks to get data in and out of the simulation while it is running:
这是创建simulink的代码传递给SIM命令的代码。金宝app
In a way similar to how we linked the app and the Stateflow chart, a handle to the app is passed to the callbacks. That way, the callbacks can access and control the app widgets. For example, here is the chain of events for the InputFcn callback:
- The user clicks the Sweep button in the app
- 扫描按钮回调会触发staflow图表中的扫描事件
- The sweep event changes the value of the "sweepVal" property defined in the Stateflow chart
- 当模拟触发输入FCN回调时,它读取的值app.curl.sweepval
- The Inport block扫描outputs the value ofapp.curl.sweepvalread in the inputFcn callback.
3D可视化
Another enhancement you probably noticed compared to the previous version is the addition of a 3D visualization.
Now it's your turn
Comments
要发表评论,请单击这里登录您的数学帐户或创建一个新帐户。