Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Andrzej Miekina
Andrzej Miekina el 9 de En. de 2020
Comentada: Andrzej Miekina el 13 de En. de 2020
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...

Respuestas (1)

Srivardhan Gadila
Srivardhan Gadila el 13 de En. de 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.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by