问题描述
我试图从simulink模型获取实时数据并在gui上显示,所以我在https://www.mathworks.com/matlabcentral/answers/446302-how-do-i-update-a-gui-designed-in-app-designer-with-data-from-a-running-simulink-model的Simulink模型回调中使用add_exec_event_listener
问题在于,函数updateGUI执行的所有结果都显示在新的GUI中(新的gui打开一次,而不是每次执行函数时都会打开)。
问题是:如何在不打开新GUI的情况下在主GUI中显示从侦听器接收到的数据。
这是updateGUI函数的代码。
methods (Access = public)
%Listener
function updateGUI(app,varargin)
% Create an object that gets the run-time value of the specified block
rto = get_param([bdroot,'/Gain'],'RuntimeObject');
currentTime = rto.CurrentTime;
app.SimTime.Text = num2str(currentTime);
% Update the GUI accordingly
sdrData = rto.InputPort(1).Data;
h1=plot(app.UIAxes,1,'r');
sdrData=sdrData.*app.W;
sdrFft = fftshift(fft(sdrData));
sdrFft=20*log10((abs(sdrFft))/2048);
% Refresh plot
set(h1,'XData',app.freqvec);
set(h1,'YData',sdrFft);
refreshdata(app.UIAxes);
drawnow;
end
end
Here is callback where simulink model executes.
function StartButtonPushed(app,event)
app.StopButton.Enable = 'on';
app.StartButton.Enable = 'off';
set_param('gsmAdGui2/Constant','Value',num2str(app.CenterFreqEditField.Value));
set_param('gsmAdGui2/Constant1',num2str(app.GainEditField.Value));
out=sim('gsmAdGui2','StartTime','0','StopTime',num2str(app.StopTimeEditField.Value));
end
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)