How do I convert the expression which is solution to a differential equation to a function?
syms T(x)
ode = diff(T,x,2) + 0.002*(20 - T) == 0;
dsolve(ode, T(0) == 40, T(10) == 200)
The output of dsolve
is an expression in variable x
. I need to change it into function.
Call matlabFunction
on the output of dsolve
to convert from symbolic expression to function handle:
syms T(x)
ode = diff(T,x,2) + 0.002*(20 - T) == 0;
s = dsolve(ode, T(0) == 40, T(10) == 200);
f = matlabFunction(s);
This produces f
as a handle to an anonymous function.