Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. You will need Professor White\'s M script rk4.m. To download this file, goto

ID: 2081299 • Letter: 1

Question

1. You will need Professor White's M script rk4.m. To download this file, goto our course web page. Click on the Class handouts etc. under the Course Materials heading, then scroll down to MATLAB Handouts and look for the entry on Numerical Methods for Systems. Right-click "rk4.m," click on "Save Link As" (or "Save Target As") and save the file. 2. Start MATLAB and change to the directory where you stored rk4.m 3. (Homework Problem for Section 4.3) Before using rk4, create a file defining the system you want to solve. Click on New Script. An Editor/Debugger box will open on the sereen. For the homework problem from section 4.3, type in the following five lines (including the last line with the word end): function w f(t, z) x (1) y (2) w C-t.*x+y; x+sin (t)] Note the between the 2 components of w end Don't forget the semicolon at the end of the second, third, and fourth lines.) save th file and return to the MATLAB command window. To use the Runge Kutta Method on the problem 2 for 0 t S 1 with n 2 subinterva tr y, y' type the commands b 1; xi. yi -2; n 2; %Note the between xi and yi [t z] rk4('f', a, b, Exi yi], n) matrix contains the computed x and y vlues. The x values are in the frit olu z, and the y values are in the second column of z. Repeat the last 2 commands with 10. OVER

Explanation / Answer

n=2 n=10 x(0.5) 1.0000 1.0000 x(1) -2.0000 -2.0000 y(0.5) -0.5260 -0.5260 y(1) -1.4377 -1.4377