How to plot the frequency Response of a FIR filter, whose transfer function depends on sampling frequency?
4 次查看(过去 30 天)
显示 更早的评论
Alberto Carboni
2015-7-23
回答: Rakshith Sharma Srinivasa
2015-8-4
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 个评论
采纳的回答
Rakshith Sharma Srinivasa
2015-8-4
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with DSP System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!