R H I T

advertisement
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 _________________/ 18 ___________/2
Problem 2 _________________/ 18____________/2
Problem 3 _________________/ 18____________/2
Total _____________________/ 60
Final Exam
Page 1 of 6
ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Problem 1 (20 points)
Consider the rocket data plotting program from exam one. The data file rocket_data.mat is still posted on day 19 and you will want to get that file again to work on this problem. Call the script for this problem lastname_problem1.m. (a) The first column of the data is time (in seconds) and the second, third, and fourth columns are rocket altitudes (in meters). Create a plot that shows the third column of data on the vertical axis and the first column of data (time) on the horizontal axis. Give the plot good labels (with units) and a good title. (b) Create a new vector which contains a 41 point moving average of the third column of the data. (Use n=20 points to the left of the point, the point itself, and n=20 points to the right of the point. This is similar to what we did on project 1. Feel free to use your code from this project.) Add this vector to your plot, and add a good legend. The moving average vector is n points shorter (at each end) than the original vector and you should not plot those points. For full credit on this part you must make the number of points in the moving average a variable (e.g. 2*n+1) rather than hardcoding it into your script, so that I could test your code with different numbers of points in the moving average and it would still be correct. (c) Print the maximum altitude that occurs in the moving average vector to the command window. Your result should look like this: The maximum altitude after the moving average is applied is 1689.92 m
When you have this working get it checked off by me on the front page. (I believe this is the correct answer.) Final Exam
Page 2 of 6
ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Problem 2 (20 points)
For this problem you must write a function and a main program. Call your function
lastname_putcircle.m and your main program lastname_problem2.m.
The function should have the following form: lastname_putcircle(c)
The function should draw a circle with radius of 10 centered at x0=c, y0=0.1 The function should also use the axis equal command so that the circles appear round on the screen.
The main program should do the following: (a) Ask the user What circles shall I place?
The answer will be a vector, and you should store it as a vector. For instance, I might answer What circles shall I place? [1 3 5]
(b) For each of the values in the vector your main routine should call the lastname_putcircle function. All of the circles should appear on the same figure. You won’t know what the values are or how many there will be until you call me over to check off your program, so you will need to write your main routine to be general. For the values [1 3 5] the figure will look like: 10
8
6
4
2
0
-2
-4
-6
-8
-10
1
-5
0
5
10
15
Recall that the equation for a circle with origin x0, y0 and radius R may be written as
cos
sin
Final Exam
Page 3 of 6
ROSE-HULMAN INSTITUTE OF TECHNOLOGY
Department of Mechanical Engineering
ME 123
Comp Apps I
Problem 3 (20 points)
For this problem, you should write a main program called lastname_problem3.m. Here you must
NOT use a function, you must use just a main routine. This problem is similar to project 3 in that we are interested in plotting the trajectory of a rocket with air drag. However, this time the value of k/m depends on altitude because at higher altitudes there is more wind. (Feel free to start with your code from project 3.) Here are the values you should use for k/m: Altitude < = 100 meters
k/m= 6.0e-5 meters-1
100 meters < Altitude <= 200 meters
k/m=10.0e-5 meters-1
200 meters < Altitude
k/m=18.0e-5 meters-1
(a) Compute and plot the trajectory of the rocket for the following conditions: Launch Velocity 250 m/s Launch Angle 30 degrees (0 is horizontal) g = 9.81 m/s dt=0.001 s Only make the computation for rocket altitudes greater than or equal to zero. (You don’t need to worry if you have one point at the end that is below zero.) Add good axis labels and a title to the plot. (b) Print the maximum rocket altitude to the command window. Your result should look like this: The maximum altitude attained by the rocket is 639.0 m
When you have this working get it checked off by me on the front page. (I believe this is the correct answer.) Final Exam
Page 4 of 6
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 5 of 6
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: (Tornado 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: (Bonfire Defense Project)
Final Exam
Page 6 of 6
Download