How to detect the change point

조회 수: 4 (최근 30일)
Mekala balaji
Mekala balaji 2018년 6월 22일
답변: Steven Yeh 2018년 6월 22일
Hi,
I want to detect the change point for example in the below data:
-32526
-32526
-32526
-32526
-32526
-32526
-32526
-32526
-25123
-25123
-25123
-25123
0.25
12562
32526
32526
32526
12326
-32526
-32526
-32526
-25123
1203
23562
32526
32526
its a time series data, and one data per sec.
I want to detect the change point, but there are small changes like 8 sec, but I want to catch if the change (in %) is >50% within 3~5 seconds. that is like at 12th second.
I use the below code, but don't know exactly how to catch what I want.
[~,~,data]=xlsread('findPeaksInput.xlsx');
data=cell2mat(data);
diff_data=diff(data);
diff_data=[0;diff_data];
diff_data=abs(diff_data);
[row,col]=find(diff_data>0);
kindly some one help, many thanks in advance,

채택된 답변

Steven Yeh
Steven Yeh 2018년 6월 22일
You pretty much have it laid out:
diff_data=diff(data);
diff_data=[0;diff_data];
percentageChange = abs(diff_data)./abs(data);
index = find(percentageChange>.5);
plot(data)
hold on
plot(index, data(index), '*')
The code above can help you detect change greater than 50% comparing to the previous point. If you want to compare 3 to 5 seconds you need to modify the diff part:
compareToPreviousData = 3; % Then you can compare to data 3 seconds ago
index = detectChange(data, compareToPreviousData);
plot(data)
hold on
plot(index, data(index), '*')
function index = detectChange(data, numSec)
diff_data = data(numSec+1:end) - data(1:end-numSec);
size(diff_data)
diff_data=[zeros(numSec, 1);diff_data];
percentageChange = abs(diff_data)./abs(data);
index = find(percentageChange>.5);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by