Runge Kutta 4th Order Example
이전 댓글 표시
I am pretty confused how to even start solving this Runge Kutta 4th order example problem in MatLab. I do know that Runge Kutta formula below, but I dont understand how to apply this example to that formula in MatLab.
Formula:
Xn+1 = Xn +1/6(k1 + 2k2 +2k3 + k4)
k1 = f(xn) t
k2 = f(xn + 1/2k1) t
k3 = f(xn + 1/2k2) t
k4 = f(xn + k3) t
Example Problem:
x(double dot) + 9x + 0.1x 3 = 0 (This is a special equation called the Duffing oscillator)
답변 (1개)
Alan Stevens
2021년 2월 19일
1 개 추천
First, write your equation as two first order equations; xdot = v, say, and vdot = -9xdot - 0.1x^3
Then define two functions fx = @(v) v; and fv = @(x,v) -9*v-0.1*x^3;
Now you need to define two sets of k1 to k4: k1x = fx(v), k1v = fv(x,v), etc.
Then you will have X(n+1) = X(n) + 1/6*(k1x + 2*k2x + 2*k3x + k4x) and V(n+1) = V(n) + 1/6*(k1v + 2*k2v + 2*k3v + k4v)
Put the whole lot in a loop representing the times for which you want the values.
If the above doesn't make any sense to you then you need to do some introductory Matlab training.
카테고리
도움말 센터 및 File Exchange에서 Runge Kutta Methods에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!