Question: The general solution to the differential equation dy/dx = x^2 - 2x is y(x) = x^3/3 - x^2 + C with y(0) = C. The
The general solution to the differential equation dy/dx = x^2 - 2x is y(x) = x^3/3 - x^2 + C with y(0) = C. The goal of this exercise is to write a function file to plot the solutions to the differential equation in the interval 0 lessthanorequalto x lessthanorequalto 5, with initial conditions y(0) = -2, 0, 2. The function file should have the structure function +f unction (similarly to the M-file myplot 1 m Example 3, page 5). The function that defines y(x) must be included in the same file Your M-file should have the following structure (fill in all the ?? with the appropriate commands): function ex5 x = ??: % define the vector x in the interval [0, 5] y1 = f (??): % compute the solution with C = -2 y2 = f (??): % compute the solution with C = 0 y3 = f(??): % compute the solution with C = 2 plot(??) % plot the three solutions with different line-styles title (??) % add a title legend(??) % add a legend function y = f(x, C) y = ?? % fill-in with the expression for the general solution end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
