How to find the maximal and minimal derivatives of noisy signals?

1 回表示 (過去 30 日間)
heikkus
heikkus 2011 年 2 月 23 日

Hello!

I'm currently using MATLAB for simple signal processing. I need to find the maximal and minimal derivatives (or slopes) of noisy signals. Actually I need the value of the derivative and the index at where it occurs so that I can draw a line representing the slope at that index. The picture below illustrates what I'm trying to do. The problem is that the signals are pretty noisy which will result in a very large derivative that doesn't represent the actual behavior of the signal. With some luck I managed to find the correct derivatives by constructing an averaged version of the original signal and calculating the average derivative over 10 samples at every index of the averaged signal. I'm sure there is a better way to accomplish this. Any help would be greatly appreciated.

採用された回答

Jan
Jan 2011 年 2 月 23 日
At first you have to decide which parts of the signal are noise. A physically motivated choice should be preferred. With this information you can create a low-pass filter such that the high-frequency signal is smoothed. With FILTFILT this filter can be applied without phaseshifting. Finnaly GRADIENT creates the derivative and MIN and MAX finds the extrema and the corresponding index.
x = rand(10000, 1);
[B, A] = butter(3, 0.2, 'low')
xFiltered = filtfilt(B, A, x);
xGradient = gradient(xFiltered);
[maxValue, maxIndex] = max(xGradient);
[minValue, minIndex] = min(xGradient);
  1 件のコメント
heikkus
heikkus 2011 年 3 月 1 日
Thank you for a quick reply! I'm now using butter() for creating and filtfilt() for applying the filter. The only fallback is that I have to create a different filter for every signal as the spectrum varies among these signals, but I guess this is as good as it gets.

サインインしてコメントする。

その他の回答 (2 件)

Vieniava
Vieniava 2011 年 2 月 23 日

Differentiator filter should satisfy your needs.

You can use it in your mfile - Differentiator filter specification object .

You could also interactively design a filter using fdatool ( doc here) - response type should be choosed as Differentiator .


heikkus
heikkus 2011 年 2 月 23 日
Thank you for a quick reply!
There seems to be a phase shift when using filters. I designed a differentiator filter and applied it to the original signal. I can now find the maximal derivative and index by using max() on the filtered signal but how would I find the corresponding actual derivative value and index of the original signal?
  2 件のコメント
Jan
Jan 2011 年 2 月 23 日
Simply use the 2nd output of MAX, which is the wanted index.
Vieniava
Vieniava 2011 年 2 月 23 日
corresponding values could be found using order of a filter. Use odd order filter - r. Than the "response delay" could be expressed as (r+1)/2 samples (see step response of designed filter on fdatool - this clarifies a lot )

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSingle-Rate Filters についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by