在MatlabGUI里面启动或者暂停Simulink模型-start_and_stop.mdl

时间:2022-09-02 07:15:57
【文件属性】:
文件名称:在MatlabGUI里面启动或者暂停Simulink模型-start_and_stop.mdl
文件大小:8KB
文件格式:MDL
更新时间:2022-09-02 07:15:57
matlab 在MatlabGUI里面启动或者暂停Simulink模型-start_and_stop.mdl 针对这个问题:https://www.ilovematlab.cn/thread-23233-1-1.html 现在我做一个集中解答,从mathworks那里学习了一下。 第一步:创建你自己的Simulink模型,这个不用我讲吧,我们使用以下模型做演示: start_and_stop.mdl 第二步:创建自己的GUI, 这个论坛里也有例子,我们使用以下文件。 start_and_stop_gui.fig start_and_stop_gui.m Figure12.jpg 在start simulation里面,直接用sim函数,这个大家好像都会: % --- Executes on button press in startsim. function startsim_Callback % hObject handle to startsim % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data modelname = get; stoptime = str2num); sim复制代码 在stop simulation,里面,callback这样写: % --- Executes on button press in stopsim. function stopsim_Callback % hObject handle to stopsim % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data global GUIStopFlag; GUIStopFlag = 1; 复制代码第三步:写一个s函数,不停地检测这个GUIStopFlag参数,发送命令给STOP按钮,告诉他,可以结束了,简单吧? sysstop_new.m 第四步:在simulink模型里面,加上这个S函数 Figure13.jpg 好了,大功告成了,现在你就可以在GUI里随意控制Simulink模型了。 注:文中所用的模型,GUI文件,由mathworks公司提供。

网友评论

  • 啥也没有这是流量 #毫无价值