GUI Graph实时更新

Real time update of GUI Graph

我已经制作了一个 simulink 模型并通过 MATLAB GUI 对其进行了 运行 连接,其中包含一个 BLDC 电机和一个控制其速度的 PI 控制器,现在的问题是当我更新输出 apeed 图时停止模拟我希望它在 运行 时间

内自行更新
% Update the string on the pushbutton
set(handles.Startstopbutton,'String','Start Simulation')

% Plot results from workspace after simulation
x = evalin('base','Scope(:,1)');
y = evalin('base','Scope(:,2)');
pHandles = plot(x,y,'Parent',handles.axesplot); 

这就是我的图表更新功能

有多种方法可以让 MATLAB UI 与 Simulink 模型进行交互 运行,包括

  1. 使用自定义 S-Function 在每个时间步将数据传递给 UI

  2. 使用事件侦听器设置为在块(信号)发生变化时侦听它们。

Use MATLAB GUI's with Simulink Models 博客更详细地讨论了这些方法。