matlab代写-CI2
时间:2021-10-09

Computational Methods II (CI2-221) Tutorial 1 Exercise 1a Jumping Jack Your cousin Jack wants to be a stunt man and intends to establish himself by jumping with a car over a river. As he is quite ambitious he has chosen river of 30 m wide, and made a hill (6m high) on either side of the river. The hills are 50m apart. Because he knows you are studying at Imperial College, he wants you to find out how fast he needs to drive to get over the river safely. If he drives too slow, he’ll crash into the second hill, and if he drives too fast he will slam into the ground far beyond the second hill. As he is unwilling to change his mind, it seems his life is in your hands. Fortunately, you have a MATLAB script that can determine the path of flying vehicles. The only thing you need to do is to create a function which describes the two hills before you can start your analysis. Download all the files from Blackboard to your work directory. - The file ex01.m is the master script for the tutorial. - The function fJumpingJack.m contains a mathematical model for the motion of Jack’s car. This function can be used as a black box: you provide the initial velocity u0 and the function for the ramp, and the function returns Jack’s horizontal and vertical position, x and y, respectively, as a function of time t. - The function fHill.m is a template for the single hill. - The function fRamp.m is a template for the ramp. You think it is a good idea to start with creating a function for a single hill, which you construct using a hyperbolic tangent function: f(x) = a ( 1− tanh2 b(x− x0) ) . (1) Here, a [L] is the amplitude of the hill, b [L−1] controls the steepness, and x0 [L] is the offset. a. Implement eq. (1) into the function fHill.m. In the master file, create a vector x which contains 200 elements in the range of 0 < x < 250 using the function linspace. Using a for-loop, create a vector y with elements yi = f(xi), using the parameter values a = 6 m, b = 0.06 m −1 and x0 = 100 m. Plot y against x. Annotate the figure1. 1A properly annotated figure has labeled axes (e.g. ’x [m]’) and has a title. When the figure contains more than one curve, a legend is required. 1 0 50 100 150 200 250 0 5 10 15 x [m] y [m ] u0=35 m/s Ramp Jack 0 50 100 150 200 250 0 5 10 15 x [m] y [m ] u0=45 m/s Figure 1: Jack’s trajectory. a) too slow; b) too fast. b. Make the function fHill.m suitable for when the input parameter x is a vector, by using elemen- twise operators2. Plot the results of the previous question and this question in one figure and show that the result is identical. Use the figure command to create a new figure window. c. Jack’s ramp can be modelled by using superposition of two individual hills. In the file fRamp.m, create the ramp by calling fHill.m twice. For both hills, a = 6 m and b = 0.06 m−1, but for hill 1, x0 = 100, while for hill 2, x0 = 150. Do not change the input parameters of framp! Plot the result, which should be identical to the ramp shown in Fig. 1. Apply the same formatting to the figure as in the previous question. d. At this point, the code fragment under ”question d” in ex01.m should reproduce Fig. 1b. Determine Jack’s vertical velocity v = dy/dt using MATLAB’s built-in gradient function. Create an annotated figure of v as a function of t. The G-force, which is related to the force that Jack experiences, is defined by G = ay g + 1, (2) where g is the gravitational acceleration. For Jack to come out of the car unhurt, G has to remain smaller than 20. e. Calculate the vertical acceleration, ay = dv/dt, and use it to calculate G. Create an annotated figure which shows G against x, together with the G = 20 limit. Would you recommend Jack to approach the ramp at 45 m/s? f. Determine, by trial and error, the velocity u0 for which the peak G-force is smallest. Write a comment in the master file which states the optimal velocity u0. 2Only use elementwise operator where necessary. Note that vectorizing fHill.m will not break the code you have written for the previous question (why?) 2


























































































学霸联盟


essay、essay代写