使用APP Designer调用Simulink模型重复打开的故障
조회 수: 16 (최근 30일)
이전 댓글 표시
我参考了这个链接:
实现了通过APP designer设计的APP打开simulink模型,并实时访问模型运行中的数据。但是问题在于,当我从app界面点击“开始”,即运行
set_param('mymodel','SimulationCommand','start');%开始运行模型
此时会重新打另一个同样的app界面。
后来我发现直接开始运行simulink模型,会自动打开一个模型并开始运行。
但我不想这样,我想通过app界面设置好模型参数后,再点击“开始”,来运行模型,并实时获取数据。
经过测试发现其中的
hApp = TrialApp;
是问题所在,就是这句代码导致界面的重复打开。但当我删了以后,就相当于断开了appdesigner和simulink的连接,这个监听程序无法运行。
我尝试了很多方法,仍然无法解决这个重复打开界面的问题,期待大佬们的回复,也欢迎同样遇到问题的朋友们一起交流,非常感谢!
댓글 수: 0
채택된 답변
Lily Yan
2023년 12월 27일
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;
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!