solution with the Runge-Kutta method HELPP

조회 수: 3 (최근 30일)
Bilal Ates
Bilal Ates 2020년 6월 25일
답변: James Tursa 2020년 6월 25일
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((x(i)+h),(y(i)+k_3*h));
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
Employ the Classical RK-4 method to integrate the given equations from x=0 to x=1 using at least one single step with the initial conditions, y(0)=2 and z(0)=4.
  댓글 수: 1
Steven Lord
Steven Lord 2020년 6월 25일
What help do you need?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support using the telephone icon in the upper-right corner of this page so we can investigate.

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

답변 (1개)

James Tursa
James Tursa 2020년 6월 25일
This is clearly a homework/exam question, so I will only offer hints. The code you have posted is for a single scalar differential equation. But you have two of these equations. You can either duplicate the stuff inside the loop for the z equation, or you can turn the code into a vector form that can handle any number of equations. I prefer the second approach because it is less code to write, and once you have written it, it will work for any number of equations. But either approach can work.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by