
可以在Matlab GUI中启动或暂停Simulink模型-start_and_stop.mdl。
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
为了解决这个问题,我们可以在Matlab GUI环境中启动或暂停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”文件。在启动仿真时,直接利用`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复制代码随后,在停止仿真时,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公司提供。
全部评论 (0)


