In this section, we will use LABVIEW MATHSCRIPT to analyze the altitude data extracted from the plot "Altitude and Acceleration Data from R-DAS" on Richard Nakk's web page. This data is in the file Altitude.csv.
We will use this data to estimate velocity and acceleration of the Frostfire Two rocket during its flight.
Download the altitude data set in the file Altitude.csv (right click on the file's link) onto your computer. Then be sure to save the file to your MATHSCRIPT working directory. This can be determined by navigating to the File/MathScript Perferences tab. The file is formatted as two columns: the first column is time in seconds, and the second column is altitude in feet. Load the data into LABVIEW MATHSCRIPT and plot the altitude as a function of time.
The following sequence of LABVIEW MATHSCRIPT commands will load the data, create a vector t of time values, create a vector s of altitude values, and plot the altitude as a function of time.
Altitude = csvread('Altitude.csv');
t =Altitude(:,1);
s =Altitude(:,2);
plot(t,s)
The plot should be similar to that in
Figure 1.
Write a LABVIEW MATHSCRIPT 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.
This solution is by Scott Jenne; it computes and plots the velocity:
Altitude = csvread('Altitude.csv');
t=Altitude(:,1);
s=Altitude(:,2);
for n=1:180;
v=((s(n+1))-s(n))/((t(n+1))-t(n));
hold on
plot(t(n),v,'o')
end
The plot produced by this code is shown in
Figure 2.
Modify your script from Exercise 2 to compute velocity and acceleration using backward differences. Remember to save your modified script with a different name than your script from Exercise 2.
This solution by Bryson Hinton:
Altitude = csvread('Altitude.csv');
t=Altitude(:,1);
s=Altitude(:,2);
for x=2:181
v(x)=(s(x)-s(x-1))/(t(x)-t(x-1));
plot(t(x),v(x),'b.')
hold on
end
The plot produced by this code is shown in
Figure 3.
Modify your script from Exercise 2 to compute velocity and acceleration using central differences. Remember to save your modified script with a different name than your script from Exercise 2 and Exercise 3.
This code computes the velocity using the central difference formula.
clear all
Altitude = csvread('Altitude.csv');
t=Altitude(:,1);
s=Altitude(:,2);
for n=2:180
v(n-1)=(s(n+1)-s(n-1))/(t(n+1)-t(n-1));
end
plot(t(2:180),v)
The plot produced by this code is shown in
Figure 4.
Compare the velocity and acceleration values computed by the different approximations. What can you say about their accuracy?
Modify your script from Exercise 2 to compute velocity and acceleration without using a for loop.
This code uses LABVIEW MATHSCRIPT's diff function to compute the difference between adjacient elements of t and s, and the ./ function to divide each element of the altitude differences with the corresponding element of the time differences:
clear all
Altitude = csvread('Altitude.csv');
t=Altitude(:,1);
s=Altitude(:,2);
v=diff(s)./diff(t);
plot(t(1:180),v)
The plot produced by this code is shown in
Figure 5.
"This course provides a brief introduction to LabVIEW MathScript, the textual math componenet of LabVIEW. The modules for this course include typical syntax and programming methods commonly used […]"