{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# rk2 - h=(b-a/N definding the step size t=a t(1)=t initial...

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

C:\matlabR12\work\rk2.m December 10, 2010 Page 1 3:52:54 PM function w = rk2(fofty,a,b,alpha,N) % function w = rk2(fofty,a,b,alpha,N) is a Matlab program to solve the IVP % by using modified 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]; % alpha is the initial value. % N is an integer represent the number of subintervals.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: h=(b-a)/N; % definding the step size. t=a; t(1)=t; % initial value of t and calculated value each step. y=alpha; y(1,:) = y'; % the initial and calculated value each step. y(1) = alpha; t(1) = a; % the main program. for i=1:N, f1 = h*feval(fofty,t,y); f2 = h*feval(fofty,t+h, y+f1); y = y+0.5*(f1+f2); t = t+h; end y(i+1,:)=y';...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online