How to plot the frequency Response of a FIR filter, whose transfer function depends on sampling frequency?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alberto Carboni
am 23 Jul. 2015
Beantwortet: Rakshith Sharma Srinivasa
am 4 Aug. 2015
Hello,
I am here because I want to plot the frequency response of a FIR filter, that is
H(e^jw) = 1/3 * (1 + e^-jwk + e^-j2wk)
the problem is that k = M/6, where M = Fs / f0 (being Fs: sampling frequency, f0 = fundamental frequency).
I am using freqz, but I cannot figure out how to include the information about k.
I cannot simply change k, since the inputs I want to pick must be shifted by pi/3 and that depends on Fs.
Thanks,
Alberto
0 Kommentare
Akzeptierte Antwort
Rakshith Sharma Srinivasa
am 4 Aug. 2015
Hi Alberto,
You can include information regarding ‘K’ while defining the numerator and denominator coefficients in the ‘freqz’ command. In this case, the numerator coefficients would look like this: B = [1/3...0….0.. 1/3 (at index K+1) ..0…0…1/3(at index 2K+1)]. For example, for K = 3,
B = [1/3 0 0 1/3 0 0 1/3];
The code snippet below delays a sine wave of frequency 100Hz sampled at 6KHz by 10 samples. 10 samples in this case corresponds to a delay of pi/3.
Fs = 6000;
f = 100;
t = 1/Fs:1/Fs:.1;
x = sin(2*pi*f*t);
plot(x);
M = Fs/f;
K = (M/6);
B = zeros(1,2*K);
A = 1;
indices = [1,K+1,2*K+1];
B(indices) = 1/3;
y = filter(B,A,x);
hold on, plot(y)
hold off
figure, freqz(B,A)
However, the above code requires K to be a multiple of 6. If the K value you are using is not a multiple of 6, you could define K as below:
K = round(M/6);
Hope it helps!
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!