Taking the derivative of a long function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Raymond Elliott
am 5 Mär. 2020
Kommentiert: Raymond Elliott
am 5 Mär. 2020
I have written out a function and I need to take the derivative of that function. However, when I try to use diff() I am getting an error. The method I am trying to use is below.
func = @(x) (1/sqrt(x))+2.0*log10(((n/d)/3.7)+(2.51/(re*sqrt(x))));
dfunc = diff(func);
It is worth noting that the only variable is x. All the other variables have been inputted by the user.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 5 Mär. 2020
diff() has two major forms. One of the forms requires that the first input is numeric, in which case it calculates numeric differences, x(2:end)-x(1:end-1)
The other form requires that the first parameter is a symbolic expression or symbolic function. This is the derivative form.
You are trying to pass a function handle to diff. No diff() is defined for that.
Unless you use the symbolic toolbox, you can can only take numeric derivatives (except for some specially constructed forms such as spline or polynomials)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!