Runge Kutta Method With Matlab

PLEASE HELP ME :)
Consider the initial value problem
y’ = t^2 + y^2, y(0) = 1.
Use the Runge-Kutta method or another method to find approximate values of the solution at t = 0.8,0.9,and 0.95. Choose a small enough step size so that you believe your results are accurate to at least four digits.
Use MatLab
Thankyou:)

4 件のコメント

Steven Lord
Steven Lord 2020 年 6 月 2 日
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.
Rifan Sinaga
Rifan Sinaga 2020 年 6 月 2 日
I got this answer, when I compared it manually, the results didn't same
f = @(t, y) t^2 + y^2;
yn= 0; tn = 0;
h = input('for h = ');
tf= 1;
n = tf/ h;
fprintf(' t y\n');
fprintf('%.3f %.7f\n', tn, yn);
for k = 1:n
k1 = f(tn, yn);
k2 = f(tn + h/2, yn + h * (k1/2));
k3 = f(tn + h/2, yn + h * (k2/2));
k4 = f(tn + h, yn + h * k3);
yn = yn + h * (k1 + 2 * k2 + 2 * k3 + k4)/6;
tn = tn + h;
fprintf('%.2f %.5f\n', tn, yn);
plot(tn,yn,'r+');
grid on; hold on;
end
Rifan Sinaga
Rifan Sinaga 2020 年 6 月 2 日
Finally, i can solbe this problem
darova
darova 2020 年 6 月 14 日
Your solution is correct. YOu can check it using ode45 built-in solver
[t,y] = ode45(f,[0 1],0);
plot(t,y)

サインインしてコメントする。

回答 (1 件)

Rifan Sinaga
Rifan Sinaga 2020 年 6 月 2 日

0 投票

Help please

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2017a

質問済み:

2020 年 6 月 2 日

コメント済み:

2020 年 6 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by