필터 지우기
필터 지우기

Best method to find maximum and minimum second derivatives of function

조회 수: 7 (최근 30일)
Yuval Levental
Yuval Levental 2020년 5월 17일
댓글: Yuval Levental 2020년 5월 20일
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
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 CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by