필터 지우기
필터 지우기

How to find first crossing of a threshold, then ignore n datapoints after?

조회 수: 42 (최근 30일)
Ethan
Ethan 2014년 10월 28일
답변: simith 2017년 9월 1일
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?

답변 (2개)

Siddharth Sundar
Siddharth Sundar 2014년 10월 29일
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
krishna kireeti
krishna kireeti 2017년 3월 7일
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
simith 2017년 9월 1일
please how to write a code to check number of up crossing and down crossing for a level in matlab

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by