Ode45 for first order differential equation (basic)
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I just started using matlab for my course and am stuck in the ode45 problem. I tried youtube and searched for answers but couldn't get through. I am trying to get some knowledge regarding this subject matter. My eqn is dy/dt=(y-1)^2. I need to graph the solutions for this equation for y(0) = 0.01,...1 at increments of 0.05. As of now i am converting the equation to first order ode and this is where i got.
function dx=ms(t,x)
dx(1) = x(2);
dx(2)=-x(1);
end
0 comentarios
Respuestas (1)
James Tursa
el 22 de Nov. de 2017
This is a 1st order ODE, so your variable will be only one element, not two elements. The derivative function will be (using your y nomenclature):
function dydt = ms(t,y)
dydt = (y-1)^2;
end
Look at the 1st order example in the ode45 doc and use your specific derivative function and initial conditions to obtain your solutions. Looks like maybe you will want to run this several times using different initial conditions?
0 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!