solution15

# solution15 - % Assignment 15 % Prob. 1 The function file...

This preview shows pages 1–2. Sign up to view the full content.

% Assignment 15 % Prob. 1 The function file used is function F=ODEP1(x,y) F=[y(2);3*y(2)-2*y(1)]; The script is as follows: Clear y0=0.5; % Initial value of y (y at x=1) y0prime=5; % Guessed initial value of y'. yf=3.3; % An assumed value of y at x=2 % which is used to start the % 'while' loop. while abs(yf-3)>=0.0001 % The while loop stops the [x,y]=ode45('ODEP1',1:2,[y0,y0prime]); % calculation when the magnitude of % the difference between the % calculated value of y at x=2 and % the correct value (3) is less % than or equal to 0.0001. yf=y(41,1); % Because the step size for x used by % ode45 is 0.025, as can be seen % the printout, the number of % values from x=1 to x=2 is 41. % Thus y(41,1) is y at x=2. This is % designated as yf. y0prime=y0prime-0.1*(yf-3)*y0prime/3; % This line corrects the initial % value of y'. The correction is % based on the difference between % the calculated value of yf and % the correct value (3). The % difference is multiplied by 0.1 % to prevent over correcting the

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/27/2010 for the course ENME 271 taught by Professor Marks during the Summer '08 term at Maryland.

### Page1 / 5

solution15 - % Assignment 15 % Prob. 1 The function file...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online