Download presentation
Presentation is loading. Please wait.
Published byToby King Modified over 9 years ago
2
We are tracking the position of an object as it is launched with an initial speed of 40m/s at an angle of 45 o. The system we are using to track the object collects measurements of the object’s horizontal and vertical position every 0.1 seconds. We need to develop a mathematical expression to allow us to predict the path of future objects launched with the same speed and angle. Our Situation…
3
1.Go to the meta-course site on Blackboard 2.Go to the Lecture Folder and locate the information for Lecture 3 3.Save the Excel file Projectile_Data.xlsx in your Current Folder in MATLAB Access the data
4
We can use the xlsread command to bring our data into Excel: >> ArrayName = xlsread('filename','CellsToBeRead'); What would the commands be for us to read in each column from the Projectile_Data.xlsx file and store them into separate vectors? Importing Data from Excel
5
Select Import Data
6
Importing Data from Excel Variable Names default to Column Headers if present and valid otherwise you get generic names. Edit to what you want. Then click on the big Green Check Mark (Import Selection)
7
Using the Basic Fitting Tool In your figure window, select Tools\Basic Fitting Different types of curves you can try to fit to your data Select what data to use Will show the equation of the curve on the graph Plots the residual value for each data point in your graph Shows the norm of the residuals on the graph of the residuals
8
Expand Tool for Additional Features
9
Projectile Data >> plot(time,height,’k*’) Use the Basic Fitting Tool What type of curve seems to fit best for the height of the projectile? Does this make sense?
10
Projectile Data >> plot(time,distance,’k*’) What type of curve seems to fit best for the height of the projectile? Does this make sense?
11
Some Recent Cases of Trying to Use Data for Prediction August 21, 2013 Rockets with Chemical Weapons were fired into Damascus, Syria. Satellite data was analyzed to try to identify the point of origin of those rockets March 8, 2014 Malaysian Airlines Flight 370 disappears on a flight from Kuala Lumpur to Beijing Satellite data and on-line flight tracking data has been analyzed extensively to try to determine the location of the plane http://www.cnn.com/2014/05/27/world/asia/malaysia-missing-plane/
12
Alternative to using the Basic Fitting Tool polyfit(x, y, N) will fit an Nth order polynomials to the set of data points (x,y). The output of polyfit is a vector of the numerical coefficients of the Nth order polynomial in descending order. polyval(polynomial, xvalues) will plug the xvalues into a given polynomial to compute the corresponding yvalues. The polynomial argument is simply a vector of the numerical coefficients of the polynomial in descending order.
13
Projectile Data >> Coeff_2nd = polyfit(time,height,2) >> yfit2 = polyval(Coeff_2nd,time); >> residuals = height – yfit2; >> residual_norm = sqrt(sum(residuals.^2))
14
>> clear % Clean out Workspace >> x = linspace(-1,2,10) % Create some data >> xlswrite('myfile',x) >> xlswrite('myfile',x,'A3:J3') >> xlswrite('myfile',x,'A5:Z5') % Too many cells, what happens? >> xlswrite('myfile',x,'A7:C7') % Not enough cells, what happens? >> xlswrite('myfile',x,'A10:A19') % Can we write a row to a column? Exporting Data to Excel
15
>> x' % Transpose x: Turns Row into Column or Column into Row ans = -0.6667 -0.3333 0 0.3333 0.6667 1.0000 1.3333 1.6667 2.0000 >> xlswrite('myfile',x','A10:A19') % Now it works ! Exporting Data to Excel
16
Double click on the variable, x, in the Workspace to open the Variable Editor Window. Can copy/paste into Excel. Variable Editor Window
17
Why bother using xlsread and xlswrite if we can use the import tool or copy/paste? Comment If you are regularly gathering data in an excel file and have some MATLAB program to analyze and present the data, using the xlsread command allows you to pull the data in automatically with your program rather than having to manually import the data every time you have a new file to work with.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.