How to find first crossing of a threshold, then ignore n datapoints after?
53 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a huge amount of data in a 2 column array. The first column corresponds to time, the second to a value at that time. I want to find all of the points at which the data crosses above a certain threshold. I am not interested when it comes back down across the threshold (it always does). This is also somewhat noisy data. My best solution was to find when x>4.7 (or whatever threshold), and then ignore everything for 50 seconds, then repeat (there should be 5 times when there's an ascending threshold cross). Unfortunately I can't get this to work...unsure of how to store these times when there is an ascending threshold cross and also can't seem to figure out a way to ignore for 50s. Any ideas?
0 Kommentare
Antworten (2)
Siddharth Sundar
am 29 Okt. 2014
If I understand correctly, you just want to be able to find the indices where your values in a vector cross a certain threshold in the positive direction while excluding the values where the threshold is crossed while moving in the negative direction.
Here is some commented script that does exactly that:
thresh = 1.7; % Specify threshold
x = [1.8 1.3 1.6 1.7 1.2 1.2 1.7 1.8 1.7 1.8 2 2.3 4.1 3 1.2 1.4 1.7 2.1];
% Essentially need to pick out values which exceed threshold with the condition that the previous value
% needs to be below the threshold
idxl = x>=thresh;
idxl(1) = 0;
idx = find(idxl);
yest = x(idx-1)<thresh;
idx(yest) % Final output
1 Kommentar
krishna kireeti
am 7 Mär. 2017
Dear sir, I had a huge data in matrix form and I want to know how many times does the data between a given period crossed the threshold value, can you help with the code?
simith
am 1 Sep. 2017
please how to write a code to check number of up crossing and down crossing for a level in matlab
0 Kommentare
Siehe auch
Kategorien
Mehr zu NaNs 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!