How to plot the frequency Response of a FIR filter, whose transfer function depends on sampling frequency?
조회 수: 3 (최근 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에서 Digital Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!