Is there a way to directly take the second derivative of data?
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In MATLAB, can I take the second derivative of data directly? Or do I need to take the derivative first using gradient, and then take the derivative of that. I am worried I am losing some precision each time, and wondering if I could go straight from y to y''.
0 Kommentare
Antworten (2)
John D'Errico
am 15 Nov. 2018
Bearbeitet: John D'Errico
am 16 Nov. 2018
Well, even gradient or diff does not actually differentiate data. They can give you an approximation to the derivative at each data point.
And, yes, you are correct to fear multiple sequential calls to gradient, as it is anapproximation at each step. The problem with numerical differentiation is it is a noise amplifiying process, sometimes called an ill-posed problem.
You don't tell us enough about your problem that I can be sure about the best approach. Is your data equally spaced in x? Is there noise in the process? This makes things more difficult.
There are several ideas you could use. I'd suggest that perhaps a Savitsky-Golay filter might be a good idea, if there is noise, and if the data is uniform in x. Or perhaps if there is no noise, then you might pass an interpolating spline through the points, then differentiate the spline twice, evaluating it at the points. Since you are looking for a second derivative, I'd probably suggest a quintic spline as a good idea. Or if there is noise in the data, then asmoothing or least squares spline canbe of value. Again, you would differentiate it at the end, and you would not incur the cost of recursive numerical differentiation.
If you truly want better advice, I would need to know more about the data, and your problem, as well as have you attach a copy of the data.
Siehe auch
Kategorien
Mehr zu Smoothing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!