Reputation: 151
I'm trying to compute the frequency response of an IIR filter.
The transfer function of the filter is:
The value of a
is computed as:
f = 1000;
fsamp = 16000;
a = 1 / (1 + (2 * pi * f) / fsamp);
Ok so now I have the transfer function of my IIR filter. How should I now compute the frequency response? I thought about using the freqz
function, but I need help defining the arguments, how do i define the numerator and denominator polynomials?
Upvotes: 1
Views: 2609
Reputation: 76
f=1000; fsamp=16000; a=1/(1+(2*pi*f)/fsamp);
a = [1 -a];
b = [(1-a) 0];
w = logspace(-1,1);
h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;
subplot(2,1,1)
loglog(w,mag)
grid on
xlabel('Frequency (rad/s)')
ylabel('Magnitude')
subplot(2,1,2)
semilogx(w,phasedeg)
grid on
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')
This is based on this solution https://www.mathworks.com/help/signal/ref/freqs.html by Mathworks. And I get this outcome:
Upvotes: 3
Reputation: 112699
The first two inputs of freqz
are respectively the numerator and denominator of the transfer function expressed as polynomials of the variable z−1:
a = 0.7; % example value
num = 1-a;
den = [1, -a];
freqz(num, den, 1001)
Upvotes: 1