Ode45 for first order differential equation (basic)
조회 수: 13 (최근 30일)
이전 댓글 표시
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
답변 (1개)
James Tursa
2017년 11월 22일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!