Main Content

데이터에서 추세 제거하기

측정된 신호에서 전체적으로 데이터의 기본 특성과 무관한 패턴이 표시될 수 있습니다. 이러한 추세는 데이터 분석에 방해가 되기도 하므로 제거해야 합니다.

추세가 각기 다른 두 개의 심전도(ECG) 신호를 살펴보겠습니다. 심전도 신호는 전원 간섭 같은 방해에 민감합니다. 신호를 불러오고 플로팅합니다.

load('ecgSignals.mat') 

t = (1:length(ecgl))';

subplot(2,1,1)
plot(t,ecgl), grid
title 'ECG Signals with Trends', ylabel 'Voltage (mV)'

subplot(2,1,2)
plot(t,ecgnl), grid
xlabel Sample, ylabel 'Voltage (mV)'

Figure contains 2 axes objects. Axes object 1 with title ECG Signals with Trends, ylabel Voltage (mV) contains an object of type line. Axes object 2 with xlabel Sample, ylabel Voltage (mV) contains an object of type line.

첫 번째 플롯의 신호는 선형 추세를 보입니다. 두 번째 신호는 비선형 추세를 보입니다. 선형 추세를 제거하려면 MATLAB® 함수 detrend를 사용하십시오.

dt_ecgl = detrend(ecgl);

비선형 추세를 제거하려면 저차 다항식을 신호에 피팅한 후 빼십시오. 이 경우 다항식 차수는 6입니다. 새 신호 두 개를 플로팅합니다.

opol = 6;
[p,s,mu] = polyfit(t,ecgnl,opol);
f_y = polyval(p,t,[],mu);

dt_ecgnl = ecgnl - f_y;

subplot(2,1,1)
plot(t,dt_ecgl), grid
title 'Detrended ECG Signals', ylabel 'Voltage (mV)'

subplot(2,1,2)
plot(t,dt_ecgnl), grid
xlabel Sample, ylabel 'Voltage (mV)'

Figure contains 2 axes objects. Axes object 1 with title Detrended ECG Signals, ylabel Voltage (mV) contains an object of type line. Axes object 2 with xlabel Sample, ylabel Voltage (mV) contains an object of type line.

추세가 효과적으로 제거되었습니다. 신호에 더 이상 기준선 이동이 없는지 확인합니다. 이제 신호를 추가로 처리할 수 있습니다.

참고 항목

| |

관련 항목