How to detect the change point
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mekala balaji
am 22 Jun. 2018
Beantwortet: Steven Yeh
am 22 Jun. 2018
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 Kommentare
Akzeptierte Antwort
Steven Yeh
am 22 Jun. 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!