MATLAB Answers

Numerically derive a continous, non-symbolic function

5 views (last 30 days)
fi on 26 Nov 2019
Commented: darova on 27 Nov 2019
I have a function defined via
function y = f(x)
% ...
. I now want to numerically calculate the value of it's derivative at a given point. As in, what should be in the following function's body?
function y = derivative_of_f(x)
% Calculate derivative of f at position x here
Is there any way to do this, without having to implement numerical differentiation myself?


Sign in to comment.

Answers (1)

darova on 26 Nov 2019
Edited: darova on 27 Nov 2019
Derivative is (if you have numerical data)
dy = (y(i)-y(i-1)) / (t(i)-t(i-1));
Maybe diff (if you have a function) ?
syms x


Show 5 older comments
fi on 27 Nov 2019
Well, the answer is currently in your comment and there is no accept button for that :(
Could you maybe edit you original answer?

Sign in to comment.

Sign in to answer this question.