6.3: Rocket Trajectory Analysis Using For Loops
This example requires an understanding of the relationships between position, velocity, and acceleration of an object moving in a straight line. The Wikipedia article "Motion Graphs and Derivatives" http://en.wikipedia.org/wiki/Motion_graphs_and_derivatives has a clear explanation of these relationships, as well as a discussion of average and instantaneous velocity and acceleration and the role derivatives play in these relationships. Also, in this example, we will approximate derivatives with forward, backward, and central differences; "Lecture 4.1" by Dr. Dmitry Pelinovsky at McMaster University http://dmpeli.math.mcmaster.ca/Matlab/Math1J03/LectureNotes/Lecture4_1.htm contains useful information about this approximation. We will also approximate integrals using the trapezoidal rule; the Wikipedia article "Trapezium rule" http://en.wikipedia.org/wiki/Trapezoidal_rule has an explanation of the trapezoidal rule.
On his web page "Richard Nakka's Experimental Rocketry Web Site: Launch Report  Frostfire Two Rocket" http://www.nakkarocketry.net/ Richard Nakka provides a very detailed narrative of the test firing of his Frostfire Two homebuilt rocket and subsequent data analysis. (His site provides many detailed accounts of tests of rockets and rocket motors. Some rocket launches were not as successful as the Frostfire Two launch; his site provides very interesting postflight analysis of all launches.)
Computation of Velocity and Acceleration from Altitude Data
In this section, we will use mfiles to analyze the altitude data extracted from the plot "Altitude and Acceleration Data from RDAS" on Richard Nakka's web page. The altitude data is available online in the file Altitude.txt http://cnx.org/content/m13277/latest/Altitude.txt We will use this data to estimate velocity and acceleration of the Frostfire Two rocket during its flight.
Exercise 16
Download the altitude data set in the file Altitude.txt onto your computer. The file is formatted as two columns: the first column is time in seconds, and the second column is altitude in feet. For this exercise you should load the data and plot the altitude as a function of time.
The following sequence of commands will load the data, create a vector of time values, create a vector of altitude values, and plot the altitude as a function of time.


load Altitude.txt ascii

t = Altitude(:,1);

s = Altitude(:,2);

plot(t,s)

The plot should be similar to that in Figure 4.
Plot of altitude versus time.
Exercise 17
Write a script that uses a for loop to compute velocity and acceleration from the altitude data using forward differences. Your script should also plot the computed velocity and acceleration as function of time.
Exercise 18
Modify your script from Exercise 17 to compute velocity and acceleration using backward differences. Remember to save your modified script with a different name than your script from Exercise 17.
Exercise 19
Modify your script from Exercise 17 to compute velocity and acceleration using central differences. Remember to save your modified script with a different name than your script from Exercises 17 and 18.
Compare the velocity and acceleration values computed by the forward, backward, and central difference approaches. What can you say about their accuracy?
Exercise 20
Modify your script from Exercise 17 to compute velocity and acceleration without using a for loop.
Computation of Velocity and Altitude from Acceleration Data
In this section, we will use mfiles to analyze the acceleration data extracted from the plot "Altitude and Acceleration Data from RDAS" on Richard Nakka's web page. Download the acceleration data set in the file Acceleration.txt available online at http://cnx.org/content/m13277/latest/Acceleration.txt onto your computer. The first column is time in seconds, and the second column is acceleration in g's. The following commands load the data and plot the acceleration as a function of time.

load Acceleration.txt ascii

t = Acceleration(:,1);

a = Acceleration(:,2);

plot(t,a)
The plot should be similar to that in Figure 5.
Plot of altitude versus time.
Exercise 21
Write a script that uses a for loop to compute velocity and altitude from the acceleration data using the trapezoidal rule. Your script should also plot the computed velocity and altitude as function of time.
Exercise 22
Modify your script from Exercise 21 to compute velocity and altitude without using a for loop.