load 'n_422.mat';

data = n_422;



fs = 250; % Sampling rate [Hz]

T = 1/fs; % Sampling period [s]

Ndata = length(data);

t = T*(0:(Ndata-1))';

data = 10.24/2048*data; % Convert to [mV]

data = [t data];



plot(data(:,1),data(:,2));

xlabel('Time (s)');

ylabel('EKG (mV)');

% return;



% Oscilloscope trace

Tlen = 2; % [s]

Nlen = floor(Tlen/T);

for i = 1:Ndata-Nlen

    seg = data(i:i+Nlen,:);

    plot(seg(:,1),seg(:,2));

    xlim([min(seg(:,1)) max(seg(:,1))]);

    ylim([-3 3]);

    drawnow;

end



% xlim([Tstart Tstart+Tlen]);