How to make the live plot run in seconds?

8 views (last 30 days)
LuYao Guo
LuYao Guo on 2 Mar 2021
Commented: LuYao Guo on 2 Mar 2021
Hello,
Can somebody please help me debug this code? I'm using a EEG data where records eye blink happens every 3 seconds. And I want to plot this in real time (second). But when I use code
drawnow limitrate
The plots seems faster than I expect. I also try 'drawnow', which gives me really slow drawing.
%Plot two channels without filters
clear
clc
close all
h = figure;
%a1 = animatedline('Color',[0 .7 .7]);
axis tight
%Sampling Frequency = 250
fs = 250;
opts = detectImportOptions("blink.txt");
%opts.VariableNamesLine = 1;
C = readtable('blink.txt');
A = table2array(C(:,23));
t = (1:height(C))/fs;
%Create subplot
sph1 = subplot(2,1,1);
axis([0 10 -18000 0]);
a1 = animatedline('Color',[0 1 1]);
xlabel('time in seconds');
ylabel('uV');
title('EEG signals in channel 1');
sph2 = subplot(2,1,2);
axis([0 10 0 18000]);
a2 = animatedline('Color',[0 1 1]);
xlabel('time in seconds');
ylabel('uV');
linkaxes([sph1,sph2],'x');
for k = 1:height(C)
%Guard addpoints call with check
addpoints(a1,t(k),C.EXGChannel1(k));
hold on
addpoints(a2,t(k),C.EXGChannel6(k));
%For scrolling window
xlim([max(0,t(k)-30) max(30,t(k))]);
%ylim('auto');
%xlimit = [t(k)-30,t(k)];
%set(a1,'xlim',xlimit);
%set([a1,a2],'xlim',xlimit);
drawnow limitrate
end
I appreciate a lot for your help!
  2 Comments
LuYao Guo
LuYao Guo on 2 Mar 2021
Hi Walter, thank you for suggestions. I've edited the part based on your suggestions but the speed of plotting is not changing at all. Do you have more ideas about this? Thank you.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!