Question: 5) The following MATLAB code performs Euler's method for an IVP. Note: MATLAB starts indexing with 1 and not 0! When we do Euler's method

5) The following MATLAB code performs5) The following MATLAB code performs
5) The following MATLAB code performs Euler's method for an IVP. Note: MATLAB starts indexing with 1 and not 0! When we do Euler's method by hand, we call our initial values xo and yo. MATLAB calls its initial values x1 and y1. So, for example, if by hand we calculated (Xo, Vo), (X1, V1), ..., (X5,)s) using Euler's method, MATLAB would calculate the same six points but they would be labeled (X1, y1), (X2, V2), .... (X6, )/6). * Euler's Method JAWNP * initial point x (1) = 0; y (1) - -2; 6 7 * dy/dx = f (x, y) f (1) = sin (x (1) ) - 3*x (1) *y(1) 43; 9 10 4 h = step size 11 - h = 0.2: 12 13 Iterations of Euler's Method (the lines between the "for" and 14 "end" commands will be repeated (51-2) +1 = 50 times) 15 16 for 1 = 2:51 17 18 * compute the new x 19 x (i) = x(i-1) + h; 20 21 * compute the new y 22 y(ij = y(i-1) + h*f(i-1) ; 23 24 * compute the new f (at our new point (x(i) , y(i) ) ) 25 f(i) = sin(x (i) ) - 3*x (i) *y(i) 43; 26 27 end 28 29 * output results as a plot 30 - plot (x, y, '-or' ) Questions on the next page5} Problem continued {refer to the MATLAB code above) a) What WP is being used in this code? (4 points) b) What is the final value for 1: lie. what is 1:51)? {4 points] c) Suppose you want to change only the NP being used in this code example. what lines would you need to change? (Just give the line numbers.) [2 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!