MATLAB GUI Updating plot
显示 更早的评论
I have a MATLAB gui that demonstrates the plotting of real-time incoming data signal and a horizontal threshold line:
axes(handles.axes1);
plot([1 windowLength].*1/sampleFreq, [-data1Threshold -data1Threshold],'k','linewidth',2);
% Plotting the threshold line
xlim([1 windowLength].*1/sampleFreq);
ylim([-300 300]);
xlabel('Time (s)')
ylabel('Filtered signal (uV)')
hold on;
plot([1:10:length(data1)].*1/sampleFreq, data1(1:10:end),'b','linewidth',2);
% Plotting the signal over the threshold line
hold off;
drawnow;
This part of the code is inside a while loop so that different parts of the signal (incoming signal) is plotted while the threshold line is identical. The issue is that the gui runs really slow. Is there anyway I can fix the threshold line and the axis information, so that I can only update the incoming signal in order to improve the speed?
I have tried the following to fix the handles to the plot, however, this still requires me to plot the threshold line and the signal at every iteration... (also not sure how to use set function with multiple data lines to plot, the threshold line and signal)
handles.plot1 = plot([1 windowLength].*1/sampleFreq, [-data1Threshold -data1Threshold],'k',[1:1:length(data1)].*1/sampleFreq, data1,'b','linewidth',2);
set(handles.plot1,'xdata',[1:10:length(data1)].*1/sampleFreq, 'ydata',data1(1:10:end));
any help will be greatly appreciated
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!