ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I FINAL EXAM – MATLAB Programming NAME ___________________________________________ SECTION NUMBER _______________________________ CAMPUS MAILBOX NUMBER _____________________ EMAIL ADDRESS ________________________________@rose-hulman.edu Problem 1 _________________/ 14 Problem 2 _________________/ 6 Problem 3 _________________/ 20 Problem 4 _________________/ 20 Total _____________________/ 60 Final Exam Page 1 of 8 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I Problem 1 (14 points) For this problem, create a single program named lastname_firstname_P1.m The behavior of a beam can be modeled by a set of four differential equations. The differential equations may be approximated by the following four Euler formulas. The equations are written in dimensionless form, so you do not have to worry about units on this problem. = + ∆ 1 − − = + ∆ = + ∆ = + ∆ For this problem, is the distance along the beam and ranges over 0 ≤ ≤ 1, and = −3and = 50. The following table provides the initial conditions at = 0 for the Euler problem. Symbol Physical Meaning Value at = 0 Dimensionless Shearing force in beam 1.5 Dimensionless Bending moment in beam -0.3 Angle with horizontal (radians) 0 Dimensionless Displacement (vertical motion divided by length) 0 By generating the solutions to the four differential equations with this Euler scheme, the displacement curve, , may be approximated. (We also get the approximations for , , and .) a. Plot the part of your solution representing the displacement curve , as a function of . Include axis labels, and the title “Displacement Curve of the Beam.” b. Find the maximum value of || and print it to the command window using the following format. The maximum absolute value of displacement in the beam is x.xxxxx. You must choose ∆ so that the displacement curve is smooth looking AND so that all 5 digits after the decimal point in Part b) are correct. Final Exam Page 2 of 8 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I Problem 2 (6 points) For this problem, create a single program named lastname_firstname_P2.m Consider the differential equation + 2 = 2 − with initial condition 0 = 1 Use Euler’s method to find the value of when = 2. Use ∆ = 0.1. Print your answer to the command window as follows: y(2)=0.9914 Note: This is the correct answer. You must have this problem completely correct in order to receive credit. Final Exam Page 3 of 8 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I Problem 3 (20 points) For this problem you will write two functions and a main program to create the plot shown. a) (6 points) Create a function which plots a circle. The function should have no outputs and three scalar inputs, and have the form lastname_firstname_circle(x0,y0,D). The function should plot a circle with diameter D centered at x0, y0. Recall that the equation for a circle with origin x0, y0 and radius R may be written as: x = x0 + R cos θ y = y0 + R sin θ 3.5 3 To ensure the circle is smooth, use 0° ≤ θ < 360° in steps of 1°. 2.5 2 Test your function to ensure it works (do not include the test in your final main code, it’s just a test): call your function using x0 = 1 , y0 = 2 , and D = 3 to ensure it produces a figure that looks like the one on the right. You may wish to use the axis square command to make the circle look circular. 1.5 1 0.5 -0.5 0 0.5 1 1.5 2 2.5 b) (8 points) You will now create a function to plot 36 circles that calls the function you created in Part a. This new function will create a ring of points to use as circle center coordinates, and plot a circle centered at each one of those points. The functions should have no outputs and two scalar inputs, and have the form lastname_firstname_ring(r,D), where r is the radius of the ring of circles, and D is the diameter of the circle to be used by the function from Part a. Test your function to ensure it works (do not include the test in your final main code, it’s just a test): call your function using r = 1 and D = 1 to ensure it produces a figure that looks like the one on the right. 1.5 1 0.5 0 -0.5 -1 -1.5 -1.5 -1 -0.5 0 0.5 1 1.5 c) (6 points) Finally create your final main program called lastname_firstname_P3.m. The main program should call the function from Part b to draw the pattern shown at the bottom-right of the page. This figure is created using three calls of the functions from Part b, as depicted below. 5 0 Final Exam Page 4 of 8 -5 -5 0 5 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I Problem 4 (20 points) For this exam problem, we will work with the data in the file Raw_data.xls and the function plot_histogram.m, both of which are posted on the course website. You will create a single program named lastname_firstname_P4.m In the data file you will find a list of numbers which we claim has a normal distribution (i.e. the results should conform to a Gaussian bell curve). Your job will be to check the data to verify our claim. Don’t worry; you don’t need to know anything about statistics to complete this problem. a) (5 points) Download the data from the website. Load the data into Matlab. Download and use the provided function plot_histogram.m to plot the distribution of the data. This function has no outputs, and two inputs, so call the function as follows: plot_histogram(y,num_bin) where: y is the data vector you read from Excel num_bin is the number bins in your histogram; use num_bin = 50 in your program Treat the resulting plot just like any other figure, so add axis labels and a title as you normally would. Use the labels and title shown below. b) (10 points) The exact function for a Gaussian bell curve is: y = ae where − ( x −b ) 2 2c2 a is a measure of the amplitude; b is the mean value of the data; c is the standard deviation of the data; for this problem use a = 600 for this problem use b = 500 for this problem use c = 5 Use this equation to plot the exact function on the same figure as the histogram you’ve already produced; use a range of 475 ≤ x ≤ 525 . Distribution of Data 700 Data Gauss fit Add a legend to distinguish between the data and the exact function. The resulting plot should look like the one shown on the right. Number of Occurrences 600 500 400 300 200 100 0 475 Final Exam 480 485 490 495 500 505 Bin Range 510 515 Page 5 of 8 520 525 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I c) (5 points) Theory states that 68.3% of the data should lie within ± one standard deviation of the mean. We computed the area under the entire curve to be approximately 7516 units, thus the area A under the curve from 495 ≤ x ≤ 505 must be: 68.3% = A × 100% 7516 ⇒ A ≅ 5133 units Compute the area A under the curve from 495 ≤ x ≤ 505 using the equation given in Part c) and the trapezoid method outlined in Day 7 Exercise 3. Use a trapezoid width of 0.1. Print the result to the command window as shown below to confirm it gives the expected area: The area under the curve between 495 and 505 is XXXX.X Final Exam Page 6 of 8 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I WHEN YOU ARE DONE, UPLOAD ALL OF YOUR M-FILES TO MOODLE. COMPLETE THE PEER EVALUATION ON THE NEXT PAGE. TURN IN THIS EXAM PAPER AND CHECK THAT YOUR FILES HAVE BEEN RECEIVED BY YOUR INSTRUCTOR BEFORE YOU LEAVE. Final Exam Page 7 of 8 ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering ME 123 Comp Apps I PEER EVALUATION: Your name (again):___________________________ Name of your partner for project 1______________________________ Comments regarding your partner for project 1: (Oil Project) Name of your partner for project 2______________________________ Comments regarding your partner for project 2: (Robot Project) Name of your partner for project 3______________________________ Comments regarding your partner for project 3: (Firefighting Project) Final Exam Page 8 of 8