Best method to find maximum and minimum second derivatives of function
4 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I created this script to find the maximum and minimum second derivatives of a given array. I was wondering what possible improvements there could be. A sample image is attached for reference.
f = tracks_2(:,2);
windowWidth = 37;
polynomialOrder = 3;
f = sgolayfilt(f, polynomialOrder, windowWidth);
plot(f);
f1 = diff(f); %diff intstantly returns the derivative
plot(f1)
f1 = sgolayfilt(f1, polynomialOrder, 37);
f2 = diff(f1); %second derivative
plot(f2)
f2 = sgolayfilt(abs(f2), polynomialOrder, 15);
[pks,locs] = findpeaks(f2,'MinPeakProminence',0.05); %maximum peaks
plot(1:length(f),f,locs,f(locs),'*')
2 件のコメント
John D'Errico
2020 年 5 月 17 日
編集済み: John D'Errico
2020 年 5 月 17 日
IF you are going to smooth your data using a Savitsky-Golay filter, then you should arguably use a similar filter to give you the estimated first and second derivatives directly.
Note that I posted a function called movingslope on the file exchange. It does exactly that, at least for the first derivative.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!