# Detect abrupt changes in signal

I'm using MATLAB and I'm trying to find the index of the first signal drop as shown in the figure bellow :

I tried the function findchangepts but it didn't give me the exact index, any solutions ?

A cheap and simple way is to differentiate the signal numerically and threshold the magnitude of differencate to identify the abrupt changes.While deciding the threshold you should take into account the dynamic range of the signal.

The Noise floor looks pretty flat. So, I can suggest a simple low cost algorithm that should work given you have enough data to learn thresholds.

1. First, estimate the noise floor of your sequence. Note that you cannot estimate noise floor by simply taking mean of the complete vector. Because that mean will give you biased result due to the impulsive drops. So, you can divide your samples in smaller windows of say, 256 samples each and then calculate the mean. And, then calculate the mean of all these windowed means. That should give you an approximate Noise floor.

2. Now, define a negative peak (or a Drop) that if a sample value $$x[n]$$ is less than $$x[n-1]$$ and $$x[n+1]$$, then it is a negative peak. You run once through your data samples and store all indices for which this criterion is satisfied. These will be your potential drops.

3. Once you have Noise floor and negative peaks, you can learn a Threshold from the Noise floor, so that if any of the stored negative peaks is below that threshold, you can store its index as a final set of negative peaks.

4. First index to survive this thresholding will be your first drop.

It is not the best but can do the job pretty easily. You can study its performance and even optimize the threshold with large number of data vectors to get a very low Probability of False Detection.

The level of fluctuations looks quite stable. You can estimate it on sliding windows with robust statistics, to limit the influence of dropping data. The simplest ones are the median and the median/mean absolute deviation, the robust counterparts of the mean and the standard deviation. If you plot them around the signal, it could appear as an envelope following the noise level (at least proportionally).

From that envelope level, with a security factor, drop detection could be possible. May be from a statistics on data above the nosie level.

Signals that are bordeline above the noise level (around 0.8 or 1.2) can be more complicated