フィルターのクリア

Symbolic toolbox: symbolic function with a function as a "variable"

1 回表示 (過去 30 日間)
Andrzej Miekina
Andrzej Miekina 2020 年 1 月 9 日
コメント済み: Andrzej Miekina 2020 年 1 月 13 日
I tried to defined symbolic function with a function as a variable:
syms y(t)
syms f(t,y(t)) - but it dosn't work
and additionally
f(t,y(t))=diff(y(t))
script below is working
% LOCAL ACCURACY OF MIDPOINT METHOD
% FOR SOLVING ODE
syms f(t,z) y(t);syms h t;
assume(diff(y(t))==f(t,y(t))) % ODE to be solved
r(h)=y(0)-y(-h)-h*f(-h/2,y(-h)+(h/2)*f(-h,y(-h))); % error
r1=simplify(subs(diff(r,h),h,0)) % first derivative of error at t=0
r2=simplify(subs(diff(r,h,2),h,0))% second derivative of error at t=0
r3=simplify(subs(diff(r,h,3),h,0))% third derivative of error at t=0
has provided correct results (i.e. derivatives of error with respect h), but in an illegible form because the instruction "simplify" has ignored the key assumption:
assume(diff(y(t))==f(t,y(t)));
in the case of r1 and r2, the result should be 0...
  1 件のコメント
Star Strider
Star Strider 2020 年 1 月 9 日
I am not certain what you want to do.
See if the compose function helps.

サインインしてコメントする。

回答 (1 件)

Srivardhan Gadila
Srivardhan Gadila 2020 年 1 月 13 日
You can define y, f & t as follows:
syms t y(t) f(t,y)
Then check for f as follows:
>> f(t,y)
ans =
f(t, y(t))
You may also refer to https://in.mathworks.com/help/symbolic/solve-a-single-differential-equation.html and related links, examples in the webpage.
  1 件のコメント
Andrzej Miekina
Andrzej Miekina 2020 年 1 月 13 日
Yes I found it and tried with compose
but how to assume that
f(t,y) == diff(y,t)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by