Differentiate an inline function
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi!
I have an assignment in Matlab and I need to find a function's 8th and 9th derivate. This function is an inline function, as it is an input from the user.
I have been trying to use the function diff, but it tells me: «Function 'diff' is not supported for class 'inline'.»
Any ideas?
6 Kommentare
Walter Roberson
am 23 Nov. 2012
syms x
f = sym(string_from_input);
diff(f,x,x,x,x,x,x,x,x)
Akzeptierte Antwort
Weitere Antworten (1)
Matt J
am 23 Nov. 2012
Bearbeitet: Matt J
am 23 Nov. 2012
You cannot do symbolic differentiation on inline functions. If you don't have the Symbolic Toolbox, you will have to either consider a specific family of functions and pre-analyze their derivatives. Or, if you want to do numeric differentiation,
t=linspace(0,T,N);
f = vectorize(inline(string_from_input));
result = diff(f(t),8)./( t(2)-t(1) )^8;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Function Creation 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!