使用APP Designer调用Simulink模型重复打开的故障
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
我参考了这个链接:
实现了通过APP designer设计的APP打开simulink模型,并实时访问模型运行中的数据。但是问题在于,当我从app界面点击“开始”,即运行
set_param('mymodel','SimulationCommand','start');%开始运行模型
此时会重新打另一个同样的app界面。
后来我发现直接开始运行simulink模型,会自动打开一个模型并开始运行。
但我不想这样,我想通过app界面设置好模型参数后,再点击“开始”,来运行模型,并实时获取数据。
经过测试发现其中的
hApp = TrialApp;
是问题所在,就是这句代码导致界面的重复打开。但当我删了以后,就相当于断开了appdesigner和simulink的连接,这个监听程序无法运行。
我尝试了很多方法,仍然无法解决这个重复打开界面的问题,期待大佬们的回复,也欢迎同样遇到问题的朋友们一起交流,非常感谢!
0 commentaires
Réponse acceptée
Lily Yan
le 27 Déc 2023
To change the run behavior of your app, select the app node from the Component Browser. Then, from the Code Options section of the App tab, select or clear Single Running Instance.
试试做成singleton吧。
或者把callback里获取句柄的方式改成这样:
% hApp = TrialApp;
hFig = findall(0,'Name','UI Figure');
hApp = hFig.RunningAppInstance;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 交互式模型编辑 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!