Kindly verify my code of DTMF decoding step
古いコメントを表示
I want to decode DTMF tones by using FIR Filter. The filters that are required to be used in filter bank are cnstructed by Sinusoidal impulse response of the form h[n]= (2/L)cos(2*pi*fb*n/fs) where 0<n<L
L is filter length fb defines the freq location of passband e.g we can pick 697Hz
the book says to generate bandpass filter for 770 Hz component with L=50 and fs=12000. This has to be done by creating a vector of filter co-efficients ,h770 which are determined by evaluatiing above stated equation. plot the filter coefficients using stem().
I have done it in this way. Is it ok
h=[];
L=50;
fs=12000;
fb=770;
for n=1:L
h(n)=(2/L)*cos(2*pi*fb*n/fs);
end
stem(h)
1 件のコメント
Jan
2011 年 10 月 9 日
Please check the results with some test data.
採用された回答
その他の回答 (10 件)
Walter Roberson
2011 年 10 月 9 日
0 投票
The description says 0 < n < L but you have n going from 1 to L which is one step too far (n == L)
3 件のコメント
Walter Roberson
2011 年 10 月 9 日
Notice the strict inequality: 0 < n < L . That means that n cannot be 0 and cannot be L, so there is no need to use "for n=0:L" (not unless the instructions are wrong.)
If the instructions had said 0 <= n <= L, then you would code as
for n=0:L
h(n+1)=(2/L)*cos(2*pi*fb*n/fs);
end
moonman
2011 年 10 月 9 日
Walter Roberson
2011 年 10 月 9 日
for n=0:L-1
h(n+1)=(2/L)*cos(2*pi*fb*n/fs);
end
moonman
2011 年 10 月 9 日
moonman
2011 年 10 月 9 日
0 投票
1 件のコメント
Wayne King
2011 年 10 月 9 日
Yes, you can confirm by looking at the frequency response
fvtool(h,1,'Fs',fs);
moonman
2011 年 10 月 9 日
1 件のコメント
Wayne King
2011 年 10 月 9 日
The big difference is that you have not plotted yours in dB
plot(ff,abs(H));
% if you plot
plot(ff,20*log10(abs(H)));
You'll see. I think it is much more common to plot these in dB.
Wayne King
2011 年 10 月 9 日
fvtool() is doing that under the hood and much more, I question why your book constructs a frequency axis in angular frequencies, when in this application Hertz makes much more sense:
[H,F] = freqz(h,1,[],fs);
plot(F./1000,20*log10(abs(H)));
grid on;
xlabel('kHz'); ylabel('Magnitude-squared (dB)');
Again, I would recommend you avoid a for loop to calculate your FIR filter coefficients and just use the vector approach I showed above.
moonman
2011 年 10 月 9 日
Wayne King
2011 年 10 月 9 日
[H,F] = freqz(h,1,[],fs);
plot(F,20*log10(abs(H)));
grid on;
xlabel('Hz'); ylabel('Magnitude-squared (dB)');
set(gca,'xtick',[697,770,852,941,1209,1336,1477]);
set(gca,'xlim',[500 2000]);
Note that you really need to limit your x-axis in order to make the labels reasonable. If you use the whole frequency axis from 0 to the Nyquist, they bunch up.
moonman
2011 年 10 月 17 日
5 件のコメント
moonman
2011 年 10 月 17 日
Wayne King
2011 年 10 月 17 日
It is often desirable to obtain power estimates, which is the magnitude squared.
moonman
2011 年 10 月 17 日
Jan
2013 年 9 月 17 日
@praveen: This request is such unfriendly, that it is funny, that you hope to be successful. It is definitely your turn to pick from these many pieces of code a program, that is working for you. Trying to push us to do your work quickly is really the wrong approach.
カテゴリ
ヘルプ センター および File Exchange で Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!