Professional Documents
Culture Documents
Week 10 Matlab Lab
Week 10 Matlab Lab
MATLAB
Week 10 Execise
Learning Objectives
Question 1:
Question 2:
Question 3:
Question 4:
A rocket is launched vertically. At time t=0, the rockets engine shuts down. At that
time, the rocket has reached an altitude of 500m and is rising at a velocity of 125m/s.
gravity then takes over. The height of the rocket as a function of time is
9.8 2
() = t + 125t + 500 for t > 0
2
(a) Create a function called calcHeight that accepts time as an input and returns
the height of the rocket.
(b) Plot height (Use the function you created in part a to calculate height.) versus
time for times from 0 to 30 seconds. Use an increment of 0.5 second in your
time vector.
Question 5:
9
TF = T + 32
5 C
9
TR = T
5 K
You will need to rearrange these expressions to solve some of the problems.
(a) Create a function called F_to_K that converts temperatures in Fahrenheit to Kelvin.
Use your function to generate a conversion table for values from 0F to 200F.
(b) Create a function called C_to_R that converts temperatures in Celsius to Rankine.
lines in the table. (Use the linspace function to create your input vector.)
(c) Create a function called C_to_F that converts temperatures in Celsius to
Question 6:
(a) Write a user-defined MATLAB function called Grade that takes test score as an
argument and return letter grade for that score based on the grading scale given
in Table 1.
Score Grade
100 or above X
85-100 HD
75-84 D
60-74 C
50-59 P
0-49 F
Below 0 X
Table1: Grading Scale
(b) Use the user-defined function you wrote for part a to calculate grade for:
Test score =85
Test score=62