Problem with plotting filter characteristics using 'freqz()' function in matlab

조회 수: 2 (최근 30일)
meysam
meysam 2023년 1월 3일
댓글: Mathieu NOE 2023년 1월 31일
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.

답변 (1개)

Mathieu NOE
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 CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by