The Islamia University of Bahawalpur: Lab Experiment # 13
The Islamia University of Bahawalpur: Lab Experiment # 13
The Islamia University of Bahawalpur: Lab Experiment # 13
LAB EXPERIMENT # 13
Performance Analysis of Basic Filters
OBJECTIVE:
Elliptic filter:
Syntax:
[b,a] = ellip(n,Rp,Rs,Wp)
[b,a] = ellip(n,Rp,Rs,Wp,ftype)
[z,p,k] = ellip(___)
[A,B,C,D] = ellip(___)
1
Code:
>> [b,a] = ellip(6,5,40,0.6);
freqz(b,a)
dataIn = randn(1000,1);
dataOut = filter(b,a,dataIn);
>>
Output:
Example: Design a 6th-order elliptic bandstop filter with normalized edge frequencies
of 0.2 and 0.6 rad/sample, 5 dB of passband ripple, and 50 dB of stopband
attenuation. Plot its magnitude and phase responses. Use it to filter random data.
Code:
[b,a] = ellip(3,5,50,[0.2 0.6],'stop');
freqs(b,a)
2
Output:
Example: Design a 6th-order highpass elliptic filter with a passband edge frequency
of 300 Hz, which, for data sampled at 1000 Hz, corresponds to 0.6 rad/sample.
Specify 3 dB of passband ripple and 50 dB of stopband attenuation. Plot the magnitude
and phase responses. Convert the zeros, poles, and gain to second-order sections for
use by fvtool.
Code:
[z,p,k] = ellip(6,3,50,300/500,'high');
sos = zp2sos(z,p,k);
fvtool(sos,'Analysis','freq')
Output:
3
4. Bandpass Elliptic Filter
Example: Design a 20th-order elliptic bandpass filter with a lower passband frequency of 500
Hz and a higher passband frequency of 560 Hz. Specify a passband ripple of 3 dB, a stopband
attenuation of 40 dB, and a sample rate of 1500 Hz. Use the state-space representation. Design
an identical filter using designfilt.
Code:
>> [A,B,C,D] = ellip(10,3,40,[500 560]/750);
d = designfilt('bandpassiir','FilterOrder',20, ...
'PassbandFrequency1',500,'PassbandFrequency2',560, ...
'PassbandRipple',3, ...
'StopbandAttenuation1',40,'StopbandAttenuation2',40, ...
'SampleRate',1500);
sos = ss2sos(A,B,C,D);
fvt = fvtool(sos,d,'Fs',1500);
legend(fvt,'ellip','designfilt')
>>
Output:
4
Low Pass Filter:
A low-pass filter is a filter that passes signals with a frequency lower than a certain
cutoff frequency and attenuates signals with frequencies higher than the cutoff
frequency. The amount of attenuation for each frequency depends on the filter
design. The filter is sometimes called a highcut filter, or treble cut filter in audio
applications.
A high-pass filter is an electronic filter that passes signals with a frequency higher than a certain
cutoff frequency and attenuates signals with frequencies lower than the cutoff frequency. The
amount of attenuation for each frequency depends on the filter design. The simple first-order
electronic high-pass filter shown in Figure 1 is implemented by placing an input voltage across
the series combination of a capacitor and a resistor and using the voltage across the resistor as
an output. The product of the resistance and capacitance (R×C) is the time constant.
5
TASK
Q) Design a 5th-order analog Butterworth lowpass filter with a cutoff frequency of 2 GHz.
Multiply by to convert the frequency to radians per second. Compute the frequency response
of the filter at 4096 points.
Code:
>> n = 5;
f = 2e9;
[zb,pb,kb] = butter(n,2*pi*f,'s');
[bb,ab] = zp2tf(zb,pb,kb);
[hb,wb] = freqs(bb,ab,4096);
plot(wb/(2e9*pi),mag2db(abs(hb)))
Output: