MATLAB --- RUNGE KUTTA 2 please help with this problem, I need MATLAB (run ready
ID: 3184454 • Letter: M
Question
MATLAB --- RUNGE KUTTA 2
please help with this problem, I need MATLAB (run ready) code for the following, using RUNGE KUTTA 2 method type algorithm.
thank you in advance
Explanation / Answer
clc;
clear all;
a=0.7;
b=0.8;
tou=13;
f=@(t,v,w)v-(v.^3/3)-w+1;
g=@(t,v,w)(1/tou)*(v+a-w*b);
h=0.2;% step length
a1=0;%lower limt
b1=1;%upper limit
N=(b1-a1)/h; %number of points
t=a1:h:b1;
v(1)=0; %intial condtion
w(1)=0; %inital condition
%RK2 Method for system
for i=1:N
m1=h*f(t(i),v(i),w(i));
k1=h*g(t(i),v(i),w(i));
m2=h*f(t(i+1),v(i)+m1,w(i)+k1);
k2=h*g(t(i+1),v(i)+m1,w(i)+k1);
v(i+1)=v(i)+(m1+m2)/2;
w(i+1)=w(i)+(k1+k2)/2;
end
v'
w'
ans =
0
0.2187
0.4790
0.7773
1.0934
1.3896
ans =
0
0.0122
0.0280
0.0478
0.0723
0.1012
Note: you have not given I value in first ode and initial conditios also u have not given, but i took and solve this . if you want u can change
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.