Help using ode45 to solve 3rd order ODE
50 views (last 30 days)
Show older comments
I'm having trouble figuring out how to use the ode45 funciton in MATLAB to solve the following 3rd order ODE:
F''' + F*F'' = 0
With initial conditions F(0) = 0, F'(0) = 1, F''(inf) = 0, and F''(0) = -0.6276.
I am new to the ode45 function, and any help would be greatly appreciated
0 Comments
Answers (1)
Ameer Hamza
on 6 Nov 2020
Convert your 3rd order ODE into a system of 3-first order ODEs
IC = [0; 1; -0.6276];
tspan = [0 10];
[t, y] = ode45(@odefun, tspan, IC);
plot(t, y);
legend({'$F$', '$\dot{F}$', '$\ddot{F}$'}, 'FontSize', 16, 'Interpreter', 'latex', 'Location', 'best')
function dFdt = odefun(t, F)
dFdt = zeros(3, 1);
dFdt(1) = F(2);
dFdt(2) = F(3);
dFdt(3) = -F(1)*F(3);
end
2 Comments
David Goodmanson
on 6 Nov 2020
Hi AJD,
Ameer's answer, while correct, does not say anything about the fact that you have a third order differential equation and four boundary conditions. That's one too many conditions, and overspecifies the problem. So you had better hope that if you use the three initial conditions at t=0, the answer will automatically end up with f''(inf) = 0. Fortunately, it does.
Ameer Hamza
on 6 Nov 2020
Correct. This was just a coincidence. This equation can only have 3 boundary conditions.
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!