How to detect the change point

1 次查看(过去 30 天)
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 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by