close all
clear all
disp('ECG')
  lw = 3; 
  set(0, 'DefaultAxesFontSize', 15);
  fs = 15;
  msize = 10;
% end of preabmle--------------------------------------

L=300; span=15;

a0 = [0,1,40,1,0,-34,118,-99,0,2,21,2,0,0,0];               % template
d0 = [0,27,59,91,131,141,163,185,195,275,307,339,357,390,440];
a = a0 / max(a0);
d = round(d0 * L / d0(15));            % scale them to fit in length L
d(15)=L;

for i=1:14,
       m = d(i) : d(i+1) - 1;
       slope = (a(i+1) - a(i)) / (d(i+1) - d(i));
       x(m+1) = a(i) + slope * (m - d(i));
end
window = ones(span,1)/span; 
sx = conv(x,window);

 figure(1)
 x = linspace(0,0.85, length(sx))
 plot(x,sx,'b-','linewidth',2);
 hold on
 plot([0.25 0.25],[-0.4 0.8],'r-','linewidth',2)
 plot([0.66 0.66],[-0.4 0.8],'r-','linewidth',2)
 axis tight
 text('Interpreter','LaTeX','String','QT','Position',[0.4 0.5],'FontSize',20)
  %print -depsc 'C:\Springer\Descriptive\Descriptiveeps\ECG.eps'




