
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!