function Hd = iir_3_5hz_3_9hz
clear;
clc;
%IIR_3_5HZ_3_9HZ Returns a discrete-time filter object.


Fs = 100;  % Sampling Frequency

Fpass = 3.5;     % Passband Frequency
Fstop = 3.9;     % Stopband Frequency
Apass = 1;       % Passband Ripple (dB)
Astop = 50;      % Stopband Attenuation (dB)
match = 'both';  % Band to match exactly


h  = fdesign.lowpass(Fpass, Fstop, Apass, Astop, Fs);
Hd = design(h, 'ellip', 'MatchExactly', match);
% Get the transfer function values.
[b, a] = tf(Hd);

% Convert to a singleton filter.
Hd = dfilt.df2(b, a);


t=linspace(0,4,400);

y1=sin(1*2*pi*t);
y2=sin(8*pi*20*t);
y3=sin(10*2*pi*t);
y4=sin(20*2*pi*t);
y5=sin(30*2*pi*t);

y=y1+y2+y3+y4;

z1=sin(2*2*pi*t);
z=z1+y2+y3+y4;
yfil1z=filter(b,a,z);
yfil2z=filtfilt(b,a,z);


yfil1=filter(b,a,y);
yfil2=filtfilt(b,a,y);
figure(1); subplot(211); plot(t,y1); title('signal by itself');
grid on;
xlabel('time'); ylabel('signal'); subplot(212); plot(t,y);
title('signal "hidden"'); xlabel('time'); ylabel('signal');
figure(2); plot(t,y1,'r'); hold on; plot(t,yfil1,'g'); plot(t,yfil2,'b');
xlabel('time'); ylabel('signal'); title('filtered and original signal für 0.4 Hz');
grid on;


figure(3); plot(t,z1,'r'); hold on; plot(t,yfil1z,'g'); plot(t,yfil2z,'b');


xlabel('time'); ylabel('signal'); title('filtered and original signal für 0.6 Hz');
grid on;
% [EOF]
