필터 지우기
필터 지우기

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개)

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 CenterFile Exchange에서 Conversion 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