Best method to find maximum and minimum second derivatives of function
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
John D'Errico
el 17 de Mayo de 2020
Editada: John D'Errico
el 17 de Mayo de 2020
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.
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!