%
%  program to remove baseline wander and apply an MA filter
%
function y = laptop3(alpha,order,name,start,samples);
%
%  load the data
%
  s = load(name);
  x = s(start:start+samples);
  N = length(x);
%
%  set the sampling frequency
%
  fs = 1000;
  time = [0:N-1]/fs;
%
%  implement the filter to remove baseline wander
%

%
%  filter the signal
%

%
%  find the frequency response of the filter
%

%
%  plot the original signal,
%    the signal after baseline drift removed
%    the signal after both baseline drift removed and MA filtering
%    the frequency response of the highpass filter
%    the frequency response of the lowpass filter
%
  figure;
  orient tall
  subplot(5,1,1); plot(time,x); grid; xlabel('Time (sec)'); ylabel('x(t)'); 
                   % axis([0 max(time) -2.5 3.5]);
                   title([' \alpha = ' num2str(alpha) ', MA filer order = ', num2str(order) ]);
%  subplot(5,1,2); plot(time,p); grid; xlabel('Time (sec)'); ylabel('p(t)'); % axis([0 max(time) -2.5 3.5]);

%  subplot(5,1,4); plot(0.5*fs*Omega1/pi,abs(H1),'-','Linewidth',1); grid; % axis([0 20 0 1]);
%                  xlabel('Frequency (Hz)');
%                  ylabel('|H_1(e^{j\Omega})|');
 
                  