% Here we are going to use the euler method to find an approximation of y(1.5) % given that the function y(x) satisfies the differential equation: % dy/dx = 2xy, y(1)=1 function [y_n] = euler1(h) format long % x is an array of n elements where n = length (x) . Initial value is 1 % and final value is 1.5 x =[1:h:1.5]; % The loop will iterate n times where n is the number of elements in % x-array. n = length(x); % The y_n array will store the values of y_n(1), y_n(2), y_n(3) etc. The first value % y_n(1) equals to 1. y_n(1) = 1; % The first element of the y_n array is set to 1 (y_n = 1). for i = 1:(n-1) y_n(i+1) = y_n(i)+h*2*x(i)*y_n(i); end % In figure 1 we plot the approximate solution %figure(1); %plot(x,y_n,'b') %hold on %a=y_n(i+1);