
Problem with plotting filter characteristics using 'freqz()' function in matlab
2 ビュー (過去 30 日間)
古いコメントを表示
I want to design a high-pass digital filter at cutoff frequency 0.5 Hz. Sampling frequency of the input signal is 500 Hz.
I tried this code:
Fs = 500; % Hz
fc = 0.5; % Hz
[b,a] = butter(12,fc/(Fs/2), "high");
[h,w] = freqz(b,a);
plot(w/pi*Fs/2, abs(h))
After running the code, I get this plot as the magnitude of the filter:

Please help me to fix this problem. Thanks.
0 件のコメント
回答 (1 件)
Mathieu NOE
2023 年 1 月 3 日
hello
I have already had that problem with high order filters designed with butter
butter will have numerical problems and the coefficients are wrong
I usually don't go beyong order 5 (always plot the result to double check)
if you really need a 12th order filter, simply put three 4th order filters in serie or use another filter design tool
Order 4 (ok)

Fs = 500; % Hz
fc = 0.5; % Hz
[b,a] = butter(4,fc/(Fs/2), "high"); % order 5 MAX !
N = 5000;
[h,w] = freqz(b,a,N);
f = w/pi*Fs/2;
ind = (f>0);
f = f(ind);
H_dB = 20*log10(abs(h));
H_dB = H_dB(ind);
semilogx(f, H_dB)
xlabel(' Hz ');
ylabel(' gain (dB) ');
title('HPF plot');
3 件のコメント
参考
カテゴリ
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!