Question

Using MATLAB Solve x - 2t = 0, (0)0,(0) = 0.1, [0, 3] by any convenient method. Graph the solution on

Use fourth-order Runge-Kutta method

0 0
Add a comment Improve this question Transcribed image text
Answer #1

chane Oint Sine u - u =) * Sin trava sysdem o ode FaiYh oxdey du t dt hgltn, un,Un) k2h tltnt unt k3-h(unt,) unt 2+ 4 ) un,

%%%%%%%%%%%%%MATLAB Code

clc;
clear all;
format long

f=@(t,u,v)v; % function 1
g=@(t,u,v)-v-u^2+2*t; % function 2

h=0.01; % step size
a=0; % initila point
b=3; % final point

  
t=a:h:b;
n=(b-a)/h; % number of points
% Initial conditons
u(1)=0;
v(1)=0.1;

%Rk4 for system
for i=1:n
K1=h*f(t(i),u(i),v(i));
L1=h*g(t(i),u(i),v(i));

  
K2=h*f(t(i)+h/2,u(i)+K1/2,v(i)+L1/2);
L2=h*g(t(i)+h/2,u(i)+K1/2,v(i)+L1/2);

  
K3=h*f(t(i)+h/2,u(i)+K2/2,v(i)+L2/2);
L3=h*g(t(i)+h/2,u(i)+K2/2,v(i)+L2/2);

  
K4=h*f(t(i)+h,u(i)+K3,v(i)+L3);
L4=h*g(t(i)+h,u(i)+K3,v(i)+L3);
  
u(i+1)=u(i)+(1/6)*(K1+2*K2+2*K3+K4);
v(i+1)=v(i)+(1/6)*(L1+2*L2+2*L3+L4);

end
plot(t,u,'linewidth',2)

xlabel('t')
ylabel('u')

3 2,5 3 1.5 1 0.5 0 0 2,5 3 2 1.5 1 0.5 t

Add a comment
Know the answer?
Add Answer to:
Use fourth-order Runge-Kutta method Using MATLAB Solve x - 2t = 0, (0)0,(0) = 0.1, [0, 3] by any convenient method. Gra...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT