MATLAB: Hi. i´m new in matlab and i can´t solve a ode using ode45 :(

reduced second order

this is my ode :
x´´ + b(t)= 0
x(0) = 1
x(1) = 0
t[0,1]
where
b(t)=-2.*(cc./(1+(cc.^2).*((t-to).^2))) + 2*(1-t).*(t-to).*(cc^3)./((1+(cc.^2).*(t-to)
"cc" and "to" are constants and i can chose them, the point is how can i do this problem using matlab :c ? , i need help

Best Answer

syms x(t) %EDITED
cc=2;
to=3;
eqn = diff(x,2) == -2.*(cc./(1+(cc.^2).*((t-to).^2))) + 2.*(1-x).*(t-to).*(cc^3)./((1+(cc.^2).*(t-to))) ;
V = odeToVectorField(eqn)
M = matlabFunction(V,'vars', {'t','Y',})
interval = [0 1];
y0 = [0 1];
ySol = ode45(M,interval,y0);
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1);
plot(tValues,yValues)