Main Content

IIR 필터로 인해 발생하는 지연 보정하기

신호를 필터링하면 지연이 발생합니다. 이는 출력 신호가 입력 신호에 비해 시간적으로 이동하는 것을 의미합니다.

무한 임펄스 응답 필터는 특정 주파수 성분을 다른 주파수 성분보다 더 지연시킵니다. 이로 인해 입력 신호가 실질적으로 왜곡됩니다. 함수 filtfilt는 이러한 필터로 인해 발생하는 지연을 보정하여 필터 왜곡을 보정합니다. 이러한 "영위상 필터링"은 정방향과 역방향에서 신호를 필터링한 결과로 얻을 수 있습니다.

1초 동안 500Hz로 샘플링된 심전도 측정값을 가져옵니다. 랜덤 잡음을 추가합니다.

Fs = 500;
N = 500;

rng("default")
xn = ecg(N) + 0.2*randn([1 N]);
tn = (0:N-1)/Fs;

75Hz가 넘는 주파수를 저지하는 필터를 사용하여 일부 잡음을 제거합니다. 통과대역 리플이 1dB이고 저지대역 감쇠량이 60dB인 7차 IIR 필터를 지정합니다.

Nf = 7;
Fp = 75;
Ap = 1;
As = 60;

d = designfilt("lowpassiir",FilterOrder=Nf, ...
    PassbandFrequency=Fp,PassbandRipple=Ap,StopbandAttenuation=As, ...
    SampleRate=Fs);

신호에 필터를 적용합니다. 필터링된 신호가 원래 신호보다 깨끗하지만, 원래 신호에 비해 시간상 뒤처져 있습니다. 또한 필터링된 신호는 필터의 비선형 위상으로 인해 왜곡되었습니다. 피크 인근을 확대합니다.

xfilter = filter(d,xn);

plot(tn,xn,tn,xfilter)

title("Electrocardiogram'")
xlabel("Time (s)")
legend(["Original Signal" "Filtered Signal"])
axis([0.25 0.55 -1 1.5])

Figure contains an axes object. The axes object with title Electrocardiogram', xlabel Time (s) contains 2 objects of type line. These objects represent Original Signal, Filtered Signal.

필터로 인한 군지연을 살펴보면 지연이 주파수 종속적임을 알 수 있습니다.

grpdelay(d,N,Fs)

Figure contains an axes object. The axes object with title Group Delay, xlabel Frequency (Hz), ylabel Group delay (samples) contains an object of type line.

filtfilt를 사용하여 신호를 필터링합니다. 지연과 왜곡이 효과적으로 제거되었습니다. 신호의 위상 정보를 반드시 그대로 유지해야 하는 경우 filtfilt를 사용하십시오.

xfiltfilt = filtfilt(d,xn);

plot(tn,xn,tn,xfilter)
hold on
plot(tn,xfiltfilt,LineWidth=2)
hold off

title("Electrocardiogram")
xlabel("Time (s)")
legend(["Original Signal" "Filtered Signal" ...
       "Zero-phase filtered with filtfilt"])
axis([0.25 0.55 -1 1.5])

Figure contains an axes object. The axes object with title Electrocardiogram, xlabel Time (s) contains 3 objects of type line. These objects represent Original Signal, Filtered Signal, Zero-phase filtered with filtfilt.

참고 항목

| | |

관련 항목