# How to find the time of beginning of the slope of the signal?

I have a time signal in MATLAB format. Sampling rate is 100k, so it is roughly 5 seconds of signal. See the link below

https://www.dropbox.com/sh/v7vev2j14i77mlk/AAA-X7JGMAzO6IyElYmFPFwra?dl=0

If you see the freq power vs time graph, you will see something below

Now I want to find the slope of the line on the freq power vs time graph (5k Hz to 15k Hz, 0.5s to 1.5s ) preciously by using the time signal. How should I handle this?

• Hi Marco. You want to use the time signal only, without any spectral information? – GKH Jan 15 '20 at 6:31
• Have you tried lowpassing and than just finding peaks? A more constructive approach would be vold kalman algorithm – Gideon Genadi Kogan Jan 15 '20 at 10:45
• @GKH I need a precious value, spectral data would do a lot of averaging. It is not good for the result – Marco Jan 15 '20 at 17:10
• @GideonGenadiKogan Trying your low passing idea – Marco Jan 15 '20 at 17:11

My suggestion:

• Segment the signal with consecutive windows
• calculate FFT for each window
• estimate FFT peaks. In your case only the first peaks is important
• the variation of the FFT peak (difference in peak location for two consecutive windows) over time (time difference between windows or window length) will give you the local slope.
• you can calculate several local slopes and obtain the average slope.
• So what you suggest is to measure the slope on the graph that I have post, right? It will be low resolution. – Marco Jan 15 '20 at 16:53
• Not directly on the graph but using some steps that are similar to the ones used to calculate the spectrogram. – Filipe Pinto Jan 16 '20 at 15:51
• I am trying your advice. I see your point. I just run a powerspecturn with 1000 sample for peak estimation. It looks good. With the sample rate 100e3 Hz, the error should be less than 0.01 second – Marco Jan 16 '20 at 18:21

My suggestion:

First, low-pass the signal @ 20 kHz. Then, since you are interested for a single component only, you could set up a Least-Squares estimation (in the time domain) for that particular component. You can take a look at the paper "Chirp rate estimation of speech based on a time-varying quasi-harmonic model" where you can process your signal in the time domain and end up with the instantaneous frequency of your component (which is what you want). Then you can process it to find the slope. The author provides some basic code for this model. It might worth a shot.

• of interest are only frequencies below 20 kHz
• there's but a single, very dominant tone in that – you've got excellent SNR
• The development of frequency over time is either constant, or a linear function of time

So, from that, I'd propose the following steps:

1. Low pass filter appropriately to restrict your bandwidth to below 15 to 20 kHz
2. employing a parametric spectrum estimator to find the frequency of your single tone
3. post-process that frequency estimate to decide whether you're still in the linear or in the constant frequency regime.

Regarding these steps:

1. might be easiest with just a simple second-order PLL. If you don't know where your tone is going to be at the start of your observation, start with a very high loop filter bandwidth, and as soon as you have a lock, reduce the bandwidth drastically. That second-order control loop actually directly gives you an error signal that you can use for 3.
2. that's a problem for a bit of low-pass filtering and estimating the frequency/time slope from that, and then checking whether the hypothesis still fits, or the slope has suddenly changed.
• My concern is "employing a parametric spectrum estimator to find the frequency of your single tone". I said that because the tone sweep from 5k to 15k. An spectrum estimator could not tell me a high resolution of timing for the frequency change from 5k to 5.001k Hz. If I just need an low resolution estimation, I could use the picture that I posted at the question. – Marco Jan 16 '20 at 6:57
• That's why I explained right afterwards that such an estimator can be just a PLL with narrow bandwidth, which is very fast. Also, the timing resolution of your estimator is still up for you to define – I'd argue that when you can see your tone sweep so smoothly in you FFT-based spectrogram, you really don't need a fine resolution at all. Every red pixel in your picture is the result of a calculation over maybe 256 to 2048 samples. – Marcus Müller Jan 16 '20 at 7:08
• Would you please give more information about PLL? I am sorry that I do not know this too much and could not find too much information from google – Marco Jan 16 '20 at 18:20
• Phase locked loop. You'll definitely find a lot on that. I promise. – Marcus Müller Jan 16 '20 at 18:33