Why does the phase response get cutoff beyond a frequency?
조회 수: 48 (최근 30일)
이전 댓글 표시
Hi, I am designing some butterworth lowpass filters of different orders and cutoff frequencies to test on some ECG data sampled at 1000 Hz. I am designing them as:
- fc = 10Hz; order = 2
- fc = 20Hz; order = 8
- fc = 40Hz; order = 8
- fc=70Hz; order = 8
I am using the same structure for all the filter designs, with just a change in variable names, like so:
fs = 1000;
fc1 = 10;
N1 = 2;
[b1,a1] = butter(N1,fc1/(fs/2),'low'); %low indicates LPF
figure('Name','LPF 20 Hz');
freqz(b1,a1,L,fs);
However I get a difference in the phase response for the 10Hz order 2 filter and the 20Hz order 8 filter. Here is the phase response of the 10 Hz filter:
and the phase response of the 20 Hz filter:
Can someone please explain why the second phase response is getting cut off abruptly?
댓글 수: 0
채택된 답변
Star Strider
2024년 10월 30일 14:57
The most likely reason is that the filter numerator coefficients are close to the limit of floating-point approximation error. This is a problem with transfer-function realisations of digital filters in general, and the reason that the second-order-section realisation is preferred.
I did the same filter with a second-order-section realisation (and initiial zero-pole-gain output from butter), and it works as desired —
L = 2^16;
fs = 1000;
fc1 = 20;
N1 = 8;
[b1,a1] = butter(N1,fc1/(fs/2),'low'); %low indicates LPF
format longG
ND = [b1; a1]
format short
figure('Name','LPF 20 Hz');
freqz(b1,a1,L,fs);
h1 = subplot(2,1,1);
h1.YLim = [min(h1.Children.YData) 50];
[z,p,k] = butter(N1,fc1/(fs/2),'low'); %low indicates LPF
[sos,g] = zp2sos(z,p,k);
SOS = sos
G = g
figure('Name','LPF 20 Hz');
freqz(sos,L,fs);
h1 = subplot(2,1,1);
% get(h1)
h1.Children.YData = h1.Children.YData - h1.Children.YData(1);
h1.YLim = [min(h1.Children.YData) 50];
.
댓글 수: 2
Star Strider
2024년 11월 2일 14:09
As always, my pleasure!
Thee floatiing-point error is siimply due to the values of the coefficients (on the order of ) so apparently beyond about 280 Hz the real and iimaginary parts of the Fourier transforms of the filter output are both 0 or close to it, and since the atan2 function that is used in the angle calculation requires the imag/real division to be performed, that produces a 0/0 result. A 0/0 result equates to NaN, and NaN values do not plot. (This iis my assumption. I did not actually explore that by calculating it.)
추가 답변 (1개)
William Rose
2024년 10월 30일 14:47
Check the values returned by freqz. Answering on my cellphone so I’m limited in what I can do. Look for NaNs at high frequencies in the computed 8th order response. The [b,a]=butter() method of specifying a filter can be unstable even at relatively low order. Try z,p,k or second order sections instead.
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filter Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!