Numerical derivative of points

Dear All: I have the y and x values and I want to get the dy/dx for each point without losing any point.What is the best way of function with a high precision to be used to find the dy/dx? Please help me with this issue. Thanks. With my best regards, Mohammed

 Accepted Answer

Star Strider
Star Strider on 30 Oct 2018
I would use the gradient (link) function. The output is the same size as the imput.

6 Comments

Thank you very much for your answer.
Dear Star Strider: I have checked the gradient function. It is assumed that the spacing between points in each direction is assumed to be 1. In my case, the spacing between points in each direction is not the same. Could explain more on this problem? Thanks. Mohammed
Did you look at the other arguments to gradient? If not, why not? That is, if you have a difference that is not 1, you can still solve the problem using gradient.
The function assumes the same spacing for the points, although it does not have to be 1. You can set it with the ‘h’ variable. One way to get ‘dy/dx’ using the function is:
h = some_value;
dydx = gradient(y, h) ./ gradient(x, h);
Experiment to get the result you want.
Thank you Star Strider.
As always, my pleasure.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 30 Oct 2018

Commented:

on 31 Oct 2018

Community Treasure Hunt

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

Start Hunting!