What's wrong with the folow expression?
1 view (last 30 days)
Show older comments
f is my imput function and i have to find the first and the second derivate.
I tried to define
df=diff(f);
f2=diff(f,2);
f1=inline (f);
df1=inline(df);
df2=inline (f2);
but appears
Error using inline (line 51)
Input must be a string." Error in convergefinal (line 11)"
df1=inline(df);
What could it be?
0 Comments
Accepted Answer
Walter Roberson
on 3 Dec 2013
diff(f) would invoke f with no arguments, fetch its return value, and apply the numeric diff() function to it, where the numeric diff() function is (X(2:end) - X(1:end-1)).
If you have the symbolic toolbox, you could try
syms t
df = diff(f(t),t);
f2 = diff(df,t);
f1 = inline(char(f(t)));
df1 = inline(char(df));
df2 = inline(char(f2));
Or more directly,
syms t
ft = f(t);
df = diff(ft,t);
f2 = diff(df, t);
f1 = @f;
df1 = matlabFunction(df, 'vars', t);
df2 = matlabFunction(f2, 'vars', t);
f
More Answers (0)
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!