What's wrong with the folow expression?

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?

 採用された回答

Walter Roberson
Walter Roberson 2013 年 12 月 3 日

0 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

質問済み:

2013 年 12 月 3 日

コメント済み:

2013 年 12 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by