Symbolic toolbox: symbolic function with a function as a "variable"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Srivardhan Gadila
le 13 Jan 2020
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.
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!