% function Hd = myfilter1
%MYFILTER1 Returns a discrete-time filter object.

%
% MATLAB Code
% Generated by MATLAB(R) 7.13 and the Signal Processing Toolbox 6.16.
%
% Generated on: 09-Jul-2015 18:02:19
%

% Equiripple Lowpass filter designed using the FIRPM function.

% All frequency values are in Hz.
Fs = 48000;  % Sampling Frequency

Fpass = 9600;            % Passband Frequency
Fstop = 12000;           % Stopband Frequency
Dpass = 0.057501127785;  % Passband Ripple
Dstop = 0.0001;          % Stopband Attenuation
dens  = 20;              % Density Factor

% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]);

% Calculate the coefficients using the FIRPM function.
b  = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);


% [EOF]

%%%% generate a signal with a frequency = Fstop as a demo
%%%%    replace this with your loaded ECG signal
t= 0:1/Fs:1;
sig= cos(2*pi*Fstop*t);

%%%% This is the statement that filters signal "sig" with filter "Hd"
output= filter(Hd, sig);

%%%% plot input and output signals overlapped 
figure(1)
plot(t,sig,'b', t,output,'r');      % global view
figure(2)
range= 1:100;
plot(t(range),sig(range),'b', t(range),output(range),'r');      % zoomed version to small time window
