ME 2016 Spring 24 Homework 1
ME 2016 Spring 24 Homework 1
Homework 1
Due: January 24, 2024
Homework 1
Due: January 24, 2024
Learning Objectives
• To familiarize ourselves with the idea that numerical methods provide approximate solutions to mathematical
problems and to see an example of how we might control the error in our approximation.
• To recall important Matlab programming concepts (i.e., script files, function files, function handles, for
loops, while loops, conditional statements, plotting, and professional formatting).
Problem description
Before releasing the parachute, the acceleration of a free-falling parachutist can be modeled by the following first-
order, linear ordinary differential equation (ODE),
𝑑𝑑𝑑𝑑(𝑡𝑡) 𝑐𝑐
𝑑𝑑𝑑𝑑
= 𝑔𝑔 − 𝑚𝑚 𝑣𝑣(𝑡𝑡), (1)
with initial condition, 𝑣𝑣 (t0 = 0) = 0. In (1), the independent variable, t, is time; the dependent variable, 𝑣𝑣(𝑡𝑡), is
the parachutist’s velocity; the parameter, m = 81.6 kg, is the parachutist’s mass; the parameter, c = 14.5 kg/s, is the
drag coefficient; and the parameter, g = 9.81 m/s2, is the gravitational constant.
Your tasks
Write a Matlab script to compute and plot the velocity of the parachutist (before releasing the parachute) over a
time interval of 30 seconds. Compare analytical and numerical (Euler’s method) solutions by plotting the following
curves on one plot:
• Plot the analytical solution computed every 1 second using a solid black line with no markers. Denote this
curve as “Analytical” in the figure legend.
• Plot the numerical solution with ∆t = 5 seconds using a dashed red line (RGB = [228, 26, 28]) with circular
markers. Denote this curve as “Numerical (dt = 5 s)” in the figure legend.
• Plot the numerical solution with ∆t = 3 seconds using a dashed blue line (RGB = [55, 126, 184]) with circular
markers. Denote this curve as “Numerical (dt = 3 s)” in the figure legend.
• Plot the numerical solution with ∆t = 2 seconds using a dashed green line (RGB = [77, 175, 74]) with circular
markers. Denote this curve as “Numerical (dt = 2 s)” in the figure legend.
• Plot the numerical solution with ∆t = 1 second using a dashed purple line (RGB = [152, 78, 163]) with
circular markers. Denote this curve as “Numerical (dt = 1 s)” in the figure legend.
Your code should be written in a script file, Script_ParachutistVelocity.m, that defines the ODE in (1) as an
anonymous function handle, and calls a function file, Euler.m (please see Fig. 2 for a possible function header), to
perform a single step of the numerical method (i.e., it should perform the update from (ti, v (ti)) to (ti+1, v (ti+1)) -
include one line of code to update t and one line of code to update v). For each numerical solution, please output
to the command window (in an easily legible way - hint: use fprintf) the time and velocity computed for each
timestep. An example of the plot and a portion of the command window output are provided in Fig. 1.
Your discussion
In your report, discuss 1) how and why the numerical curves differ for different values of ∆t and 2) what aspects of
your code make it modular and why.
1
ME 2016 Homework 1 Due: January 24, 2024
Deliverables
Please place all files described below (e.g., .docx, .pdf, .m) in a zipped folder and upload to Canvas using the
following naming convention: “HW#_FamilyName_FirstName.zip.”
(a) Professionally-formatted report. Please provide a brief description of the problem, an image of the plot
output by your code, a screenshot of the command window output from your code for the
∆t = 5 case, and the discussions indicated above. Be sure to format your report professionally. Your plot
should include meaningful axis labels with units, a legible legend, and curve formatting as specified above.
Matlab’s “grid on” and “box on” commands are also suggested. Your report should include a header/footer
with your name, date, course number, assignment number, and page number. (See templates posted on
Canvas)
(b) Professionally-formatted source code. Include Script_ParachutistVelocity.m, Euler.m, and any other
functions (if any) that you wrote to complete the assignment. Please be sure that your code runs
directly upon download of your zip file. Be sure to format your code professionally. At the top of each
script/function, include your name, the date, and a description of the file - for functions also define all
input and output variables. Use comments and indenting for code readability.
Figure 1: Freefalling velocity of a parachutist over an interval of 30 s after starting from rest: (a) Comparison of
analytical solution to four numerical solutions with different stepsize, ∆t; (b) Command window output of time and
velocity for each time step for the ∆t = 5 s case. (this is sample data - your results will most likely be
different)