필터 지우기
필터 지우기

Runge-Kutta method

조회 수: 1 (최근 30일)
Aslam Ali
Aslam Ali 2020년 8월 6일
댓글: John D'Errico 2020년 8월 15일
Write the Matlab / C++ routine of Runge-Kutta method of Order four for the following problem
y^'-y=3x^2,y(0)=4
for the range 0.1≤x≤0.5, by taking h=0.025.
Note: Please give proper answer, this question is fro numerical analysis.
  댓글 수: 3
Aslam Ali
Aslam Ali 2020년 8월 6일
I can't attempt this question because i didn't understand it please if anyone know the answer and code then kinly share it
Steven Lord
Steven Lord 2020년 8월 6일
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

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

답변 (1개)

esat gulhan
esat gulhan 2020년 8월 15일
%RUNGE KUTTA METHOD OF ORDER FOUR
clc;clear; % Clears the screen
h=0.025; % step size
x = 0.1:h:0.5;
y = zeros(1,length(x));
y(1) = 4; % initial condition,y(1) is y(0) value
F_xy = @(x,y) 3*x^2+y; % function
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
for i=1:(length(x))
fprintf('%12.5f',x(i),y(i));fprintf('\n')
end
You should use ode45 formula in order to this formula, you can solve this problem with dsolve.
  댓글 수: 1
John D'Errico
John D'Errico 2020년 8월 15일
Please don't do homework assignments for people. This teaches them nothing, except how to get someone else to do their work for them.

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

Community Treasure Hunt

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

Start Hunting!

Translated by