Is it possible to get the derivative of a function_handle as a other function_handle?
Like:
fun1 = @(x) x^2;
% do that ...
disp(fun2);
@(x) x*2
I know how to find the derivative of a symbolic function but I can't convert a function_handle to a symbolic function.
I'm new to matlab and I couldn't find any way on doing that. Thanks in advance.
To take the derivative of a function by using the definition, substitute x plus delta x into the function for each instance of x. Then, substitute the new function into the limit, and evaluate the limit to find the derivative.
The short answer is "No." MATLAB has no idea what the contents of the function_handle mean in a symbolic sense. You're better off creating it using syms
in first place.
A longer answer would be either to use the Symbolic Math Toolbox, as suggested by @A Danesh, or an approximation, as suggested by @Andrey.
However, if you're always working with polynomials, then you can store the coefficients as an array and use the following functions:
polyval
to evaluateconv
to multiplydeconv
to dividepolyder
to differentiatepolyint
to integrateIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With