Euler method

Euler method - % alpha is the initial value. % N is an...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
C:\matlabR12\work\euler.m December 10, 2010 Page 1 3:51:31 PM function w = euler (fofty,a,b,alpha,N) % function w = rk2(fofty,a,b,alpha,N) is a Matlab program to solve the IVP % by using euler method. % Inputs: % fofty is a name of m-file which evaluates the function f(t,y). % a and b is the endpoints of the interval [a,b];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % alpha is the initial value. % N is an integer represent the number of subintervals. h =(b-a)/N; % initialized the values of y and t. y(1) = alpha; t(1) = a; % the main loop for calculating the values of y. for i = 1:N, y(i+1) = y(i)+ h*feval(fofty,t(i),y(i)); t(i+1) = t(i) + h; end y(N)...
View Full Document

Ask a homework question - tutors are online