%function Hd = test2
%TEST2 Returns a discrete-time filter object.

%
% MATLAB Code
% Generated by MATLAB(R) 7.14 and the Signal Processing Toolbox 6.17.
%
% Generated on: 04-Oct-2016 20:17:33
%

% Butterworth Lowpass filter designed using FDESIGN.LOWPASS.

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

Fpass = 60;          % Passband Frequency
Fstop = 90;          % Stopband Frequency
Apass = 1;           % Passband Ripple (dB)
Astop = 40;          % Stopband Attenuation (dB)
match = 'stopband';  % Band to match exactly

% Construct an FDESIGN object and call its BUTTER method.
h  = fdesign.lowpass(Fpass, Fstop, Apass, Astop, Fs);
Hd = design(h, 'butter', 'MatchExactly', match);

% [EOF]
%------------------------------------------------------------------
f1= 100;            % signal 1: 100 Hz
f2= 40;             % signal 2: 40 Hz   

T= (1/f1)*1/10;     % sampling period = signal period x 1/10
N= 200;             % number of points - arbitrary
t= 0:T:(N-1)*T;         % generate time points to use for computing the signal
s1= cos(2*pi*f1*t);  % generate the signal
s2= cos(2*pi*f2*t);  % generate the signal
ss= s1+s2;           % sum signal = s1+s2

ssf= filter(Hd, ss); % filtered signal   

figure(1)
%plot(t,s1,'ro-',t,s2,'bs--')
plot(t,ss,'b',t,ssf,'r')
