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,
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File 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!