I am plotting live data: for the plotting, I am using the line function, which improved the plotting performance a lot compared when using the plot function. Still, the plot gets slower with time. I realized that the sample points that I am creating are plotted, but even when they are not visible later the still remain in the plot. Could this cause any performance degradation?
I just want to see the sample points of the current three seconds, if use clf or cla function, just see very small part of the signal, which is not helpful for me. Do you have any suggestions?
%% opening function:
handles.figureHandle=figure;
guidata(hObject, handles);
t=1/200; %sample rate 5ms
%% button function:
if 40< newSamples
figure(handles.figureHandle)
t = max(t) + (1:size(sample,1)) * 1/200;
for x=1:8
subplot(8,8,x);
hold on
line('XDATA',t,'YDATA',sample(:,x),'MarkerSize', 1,'Color','r');
ylim([0 1024]);
xlim([max(t)-1 max(t)+2]);
hold off
end
drawnow ;
end
Update
%% opening function
sample=[];
t=[];
handles.figureHandle
for i=1:8
subplot(2,2,i);
hold on
h=line(t,sample,'MarkerSize', 1,'Color','r');
% ylim([0 1024]);
% xlim([max(t)-1 max(t)+2]);
hold off
end
t=1/200;
%% button function
figure(handles.figureHandle)
t = get(gca, 'XData');
sample = get(gca, 'YData');
t = max(t) + (1:size(sample,1)) * 1/200;
for x=1:8
set(h,'XData',t,'YData',sample(:,x));
end