How do I interpolate derivative values at endpoints with interp1?

7 views (last 30 days)
Hello,
I've created a function that uses central difference approximation (f'(x) = (f(x + h) - f(x - h))/2h) to calculate the derivative of a signal (Fn=0.8x+sin⁡(0.3πx)). Right now, I have the derivative for the first and last elements of the series for the signal set to equal zero, but I want to change this function so that it uses interpolation to estimate the derivative at these points. Attached are both the function (timederiv.m) and the script I'm calling it in (lab8_script.m) for clarity.
Any help would be greatly appreciated, thank you!

Answers (1)

Torsten
Torsten on 31 Mar 2022
Look at the forward (first element) and backward (last element) finite difference coefficients in the link and choose those you like (adequate are those that give 2nd order approximation at the boundaries since central differencing in inner points is 2nd order).

Community Treasure Hunt

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

Start Hunting!