BY MATLAB CODE ONLY BY MATLAB CODE ONLYBY MATLAB CODE ONLY S

BY MATLAB CODE ONLY

BY MATLAB CODE ONLY...BY MATLAB CODE ONLY

Solve the following set of differential equations using Euler\'s method, assuming that at x = 0, y_1 = 4, and y_2 = 6. Integrate to x = 2 with a step size of 0.5. dy_1/dx = -0.5y_1 dy_2/dx = 4-0.3y_2 - 0.1 y_1

Solution

Matlab code

% Euler Mathod
clear all
clc
dx=0.5; % step size
N=4; % number of steps
x(1)=0;
y1(1)=4;
y2(1)=6;
for i=1:1:N
x(i+1)=x(i)+dx;
y1(i+1)= y1(i)+dx*(-0.5*y1(i)); %dy1/dx=f1=-0.5y1
y2(i+1)= y2(i)+dx*(4-0.3*y2(i)-0.1*y1(i)); %dy2/dx=f2=4-0.3y2-0.1y1
end
y1 %y1(0.0),y(0.5),y(1.0),y(1.5),y(2.0) that is y1 values at x=0 to x=2
y2 %y1(0.0),y(0.5),y(1.0),y(1.5),y(2.0) that is y2 values at x=0 to x=2

Output

y1 =

4.0000 3.0000 2.2500 1.6875 1.2656

y2 =

6.0000 6.9000 7.7150 8.4453 9.0941

BY MATLAB CODE ONLY BY MATLAB CODE ONLY...BY MATLAB CODE ONLY Solve the following set of differential equations using Euler\'s method, assuming that at x = 0, y

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site