Solving ODE in MATLAB using Runge-Kutta method of order 4

조회 수: 8 (최근 30일)
Shankhadeep Saha
Shankhadeep Saha 2021년 12월 11일
댓글: Shankhadeep Saha 2021년 12월 14일
Write a computer program that will solve the initial value problem dy/dx = f(x, y) subjected to y(x0) = y0 by classical fourth order Runge-Kutta method.
Inputs: x0, y0, f(x, y), h = step-size, and n = number of steps. Using the code obtain the solutions of the ODE
Compare each numerically obtained solution with corresponding analytical solution by plotting them in a single figure.
  댓글 수: 9
James Tursa
James Tursa 2021년 12월 14일
편집: James Tursa 2021년 12월 14일
Still not clear. Is the user supposed to know that z is dy/dx? How would they know this? Is the user supposed to enter a function handle directly using x, y, and z with the assumption that z is dy/dx?
Shankhadeep Saha
Shankhadeep Saha 2021년 12월 14일
Yes, the user knows that. He will input the function interms of x, y and z. Like in this particular case user will input g(x,y,z) = sin 2x -0.2z-y = dz/dx

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

답변 (1개)

James Tursa
James Tursa 2021년 12월 14일
Why aren't you using this to update z:
z(i+1) = z(i) + (1/6)*(l1+(2*l2)+(2*l3)+l4);

카테고리

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