MATLAB Practical Exam Practice
Problem #1: Data File Processing
You are working with a large data file with multiple rows and columns of data. Using the file
[Link] on Canvas, write a MATLAB program (script m-file) with lines of code to accomplish
the following tasks:
1. Import the numeric data contained in the file into the workspace stored in a variable (using the
load function)
2. Create vectors for the individual columns of data
3. Determine the number of entries in a column of data
4. Loop through each position in your vector to do the following:
A. Build a vector representing time which corresponds to the sampling times for the entries
in the column of data from Step 2.
B. Count the instances of occurrence of specific events where column A is between 10 and
100 and column B is between 500 and 1000. Count only if all conditions are true.
C. Build two vectors for values that meet the criteria in Step 4B, one for column A values
and one for column B values.
D. Report the results of values stored in the vectors from Step 4C to the user in formatted
and identified output
5. Plot the data in the columns from Step 2 (column B on the y-axis, column A on the x-axis) and
add axes’ labels and a plot title
MATLAB Practical Exam Practice
Problem #2: Auto Open Parachute Analysis
Problem Statement
A parachutist jumps out of an airplane at a height of 1000 meters above ground. You are challenged
with developing a program which will open the parachute once the parachutist reaches terminal velocity.
Terminal velocity is reached when the magnitude of drag force equation (below) equals the force of
gravity. For the sake of easier modelling we will define terminal velocity occurring when the absolute
magnitude of acceleration is less than 0.05 . Your analysis should complete the calculations below
once at each time step and continue while height greater than zero. The time interval for each iteration
should be set to 0.01 seconds.
Initializations
Cd (human) = 1.1
Cd (parachute) = 1.5
area, A (human) = 0.7
area, A (parachute) = 15
mass, m = 90 kg
density (air), = 1.1
height, h (initial) = 1000 m
time, t (initial) = 0 s
time, t_step (interval) = 0.01 s
gravity, g = -9.81
velocity, v = 0
acceleration, a = -9.81
Equations
(1) ∙ ∙ ∙ ∙ , with Fdrag in N, in kg/m3, A in m2, Cd is unitless, and v in
(2) ∙ , with m in kg, g in , in N, and in N
(3) / , with in N, m in kg, and a (acceleration) in
(4) Δv = ∙ _ , with a in , t in s, and Δv in
(5) v (current) = v (previous) + Δv, all velocities in
(6) Δh = ∙ _ , with v in , t in s, and Δh in m
(7) h (current) = h (previous) + Δh, all heights in m
Note: When terminal velocity is reached, both the area and coefficient of drag change (see
initializations above), but the rest of the drag force equation remains the same. Change area and
coefficient of drag using a selection structure inside the loop.
Outputs
Store height, velocity, and time in a vector
Plot height and velocity with respect to time on the same graph
Report terminal velocity ( ) – Hint: maximum magnitude in vector of velocities
NOTE – DO NOT USE Kinematic equations from your physics class
MATLAB Lab Practical Practice
Problem #3: Percent Error Calculation
Problem Statement:
As a research engineer, you are responsible for calibrating a piece of laboratory equipment.
Recently you ran several tests on the apparatus to collect test data and now you need to compare
it to calibration data to look for discrepancies.
In this case, when the percent error between the calibration data and test data exceeds 5%:
1. When does this occur in terms of time (seconds)?
2. What is the percent error at that time?
Using the directions that follow, you should create a MATLAB algorithm to load, analyze and
output the desired results. This problem requires the use of a separate function to calculate the
percent error.
Note: Underlined words indicate the preferred variable name for use in the algorithm.
1. Start a new MATLAB script file.
2. Use xlsread, to import the data (Data_final.xlsx).
3. Extract data associated with Time, Calibration and Test A into vectors named time, calib,
and testA respectively.
4. Start a new function file.
5. The function should use a while loop to determine the percent error between the test and
calibration data for each time step, up to 60 seconds.
6. Within the loop, build vectors for when the percent error exceeds the limit (when), and a
corresponding vector of the percent error at that time (error).
7. The function should output the vectors when and error, but also use a formatted print
statement to say, “A percent error of X% occurred at Y seconds.”
8. Update the MATLAB script file to properly call and execute the function.
9. On the same formated figure: plot time versus calib using a continuous blue line;
plot time versus testA as red triangles