Write a function file that utilizes Eulers method to solve t
Write a function file that utilizes Euler\'s method to solve the following differential equation to within 10^_6 tolerance of the exact value. dx(t)/dt = 1.2 x - 0.6 xy dy(t)/dt = -0.8 y + 0.3 xy x(0) = 2, y(0) = 1
Solution
Matlab code for Eulers method
function y=y(n,t0,t1,y0)
h=(t1-t0)/n;
t(1)=t0;
y(1)=y0;
for i=1:n
t(i+1)=t(i)+h;
y(i+1)=y(i)+h*ex(t(i),y(i));
end;
V=[t\',y\']
plot(t,y);
SAVE THE AVOVE FILE IN THE NAME OF euler.m
next create 1 more function file named according to your wish
function y=y(t,x)
%%% mention the differential equations in above function form
%% for example
y=1.2t-0.6tx;
%%%%%%%%%%%%
in the command window write euler(n,t0,t1,y0) put the values of n , t0,t1, yo ... you will get the numerical values and a graph.
Properly write the differential equations you will get the results .
