Numerically derive a continous, non-symbolic function

5 visualizaciones (últimos 30 días)
fi
fi el 26 de Nov. de 2019
Comentada: darova el 27 de Nov. de 2019
I have a function defined via
function y = f(x)
% ...
end
. 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
end
Is there any way to do this, without having to implement numerical differentiation myself?

Respuesta aceptada

darova
darova el 26 de Nov. de 2019
Editada: darova el 27 de Nov. de 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
diff(f(x))
  8 comentarios
fi
fi el 27 de Nov. de 2019
Well, the answer is currently in your comment and there is no accept button for that :(
Could you maybe edit you original answer?
darova
darova el 27 de Nov. de 2019
yes please

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by