# Detecting and extracting end points of signal in larger signal

I have the following time series current measurement recordings at 5,000 samples per seconds for 10 minutes:

I am trying to find a way to extract the recordings of the periodic intervals that are higher in current consumption as shown in the picture below:

These periodic portions come every 120ish seconds. However, their interval duration is not constant, i.e. you can notice how the width changes. So I want to get the starting and end points to be able to extract that portion and do some analysis on it.

Here are three intervals extracted manually and plotted:

I have been trying various things attempting to extract this portion but wasn't successful. Maybe I am following the wrong methods overall. I am doing this in MATLAB and I am not a DSP expert.

The latest thing I have tried to do is a simple moving average with a lag of 5,000, i.e. the sampling rate, using the MATLAB function tsmovave(data, 's', 5000) and I got the following:

However, the signal doesn't look clean enough to apply simple thresholds on it and pull out what I need.

I also tried to increase the lag time to 120 seconds (i.e. the period interval) and then attempted to extract minimums and maximums using the MATLAB function findpeaks(), but that didn't work because there are a lot of local minimums and maximums in the data. So I tried to resample at a lower rate but that still didn't work.

Someone suggested that I should use matched filter and provide a manually extracted interval to the filter. Another method I came across in my research is implementing some sort of step-finding algorithm.

From your experience, what's the best way to go about doing this DSP. It seems like a simple problem but I spent a lot of time trying to solve it and couldn't. I am not an expert in DSP. I appreciate any feedback and direction.

• The question should perhaps be migrated to dsp.stackexchange.com
– Gala
Commented Jul 1, 2013 at 5:34