Runge-Kutta method related

조회 수: 2 (최근 30일)
KSSV
KSSV 2012년 5월 8일
Hi
I have a doubt (rather a confusion) in Ruge-Kutta method. I want to time integrate an equation of the form
dy/dt = g*n-0.5*(u^2+v^2)
Where g,n,u and v are known. So I can put equation in the form
dy/dt = a constant
I want to time integrate it in the time span [ti tf]. As the equation have constant on right side and no time, no y variable, how I can time integrate it? I have initial conditions for y. If I use ode45 how I can call ode45? How the equation should be fed to ode45?
Thanks in advance
Sreenu

채택된 답변

Richard Brown
Richard Brown 2012년 5월 9일
Why are you bothering to use ode45 at all?
Your solution for any t >= ti is just
y = y0 + (t - ti) * (g*n-0.5*(u^2+v^2));
  댓글 수: 4
KSSV
KSSV 2012년 5월 10일
Dear Richard
Perfect. Yes, we can solve the equation by using first order difference;
y = y0 + dt*(g*n-0.5*(U^2+v^2))
This what I have followed. The author says, RK4 will be of less error compared to first order difference. So, no option at last I have to integrate using RK4.
Jan
Jan 2012년 5월 10일
No doubt, Richard, you hit the point: The integration of a constant is trivial. +1

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2012년 5월 8일
Did you read the documentation for ODE already? There is a nice example, which you can modify easily.
  댓글 수: 2
KSSV
KSSV 2012년 5월 9일
I used ODE45 n number of times, I know how to invoke/call ODE45. I already mentioned that my equation happens to be of the form
dy/dt = K
I am confused of the methodology to be applied in this case. I tried ODE45 for the equation, but the results are not satisfactory.
Jan
Jan 2012년 5월 9일
편집: Jan 2012년 8월 19일
Please post how you have implemented the function to be integrated and explain "not satisfying" with any details. The solution seems to be trivial: function dy=myFunc(y, t) dy = 15.3; % Or what ever the constant value is
You can integrate the function dy/dt=K in closed form also.
Perhaps you are looking for an anonymous function to define the constant value externally. Then see: http://www.mathworks.com/matlabcentral/answers/1971-when-using-ode45-or-similar-functions-what-is-the-benefit-of-using-anonymous-functions-over-passi Another idea is to search for the term "ODE45" in this forum.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by