Hello, I solved this question using ode45. But I'm having trouble solving for y(t) using finite difference method. Here is the code I have so far. Can you explain to me how to use finite difference method on this problem? Thanks.
clear allclose allc=0.0001;g=9.81;%dy/dt=v
%dv/dt=-cv^3-g
%ODE system dy_dt=F(t,y)
F = @(t,y) [y(2);-c*(y(2))^3-g];%dy-dt=f(t,y)
f = @(t,y) -y;%initial conditions
y0 = [40;0];%Numerical solution using ode45
[t,yNumerical]=ode45(F,[0 5],y0);%Analytical Solution
figureplot(t,yNumerical(:,1),'--o','LineWidth',2)hold onplot(t,yNumerical(:,2),'--o','LineWidth',2)legend('Position','Velocity')
Best Answer