In the first part of this lab, you will explore basic concepts in the regression of nonlinear data via a guided analysis of projectile motion data. (Refer to pages 4 and 7 of the R05. Data Analysis reading handout for a detailed discussion of regression.) As part of the analysis, you will make use of the linfit function that you created in the previous lab exercise. In the second part of the lab, you will apply the concepts and techniques to analyze sample data from an electrical circuit.
Although a complete discussion of nonlinear regression is beyond the scope of this course, the following approach can be used to analyze data in many engineering problems:
algebraically rearrange the theoretical equation to match either a linear (y = m x + b) or polynomial (an xn + ... a2 x2 + a1 x + a0) general form;
map the variables and constants in the theoretical model to those in the general equation;
perform least squares regression of the data to the general equation (i.e., determine the best-fit parameter values m & b or a0, a1, etc. that minimize the sum-squared residuals);
use the mapping to determine values of the parameters in the original theoretical model.
Part A. Exploring Regression of Nonlinear Data
In this first part of the lab, you will analyze hypothetical data from projectile motion experiments similar to those described in previous labs. In this case, the data reflect horizontal distances xmax achieved by projectiles launched at various initial velocities V0, at a constant angle θ of 30°.
1. At the command line, create a matrix variable containing the following data and save it to a file flightdata.txt
V0 (m/s) 5 10 15 20 25
xmax (m) 2.2 9.1 18.8 36.1 54.5
2. In a script file, translate the following pseudocode into working MATLAB code. Verify that the plot appears as expected.
% clear all variables in the workspace
% close all figure windows
% load data from the file flightdata.txt
% extract data into vector variables V0 and xmax
% plot xmax as a function of V0 using symbols for the data points
% label the graph with a title, axis labels, and units