Question: The Assignment First, download the CSV file with the data that you ll work with ( see the Downloads section ) . The file you

The Assignment
First, download the CSV file with the data that youll work with (see the Downloads section).
The file you download, streifCourseRecords.csv contains 2 columns of data:
The year the record was set
The time in number of seconds (to the 1/100th of a second)
Then you are required to do the following:
Open the streifCourseRecords.csv CSV file and read the data into a matrix
Plot the year (as the X-axis) and time in seconds (as the Y-axis)
Title the plot, along with providing labels for the X and Y axes
Use the built-in function polyfit function to generate the coefficients of both the 1st and 2nd order polynomials that best-fit this data
Create your own function that calculates and returns the coefficients of the 1st order polynomial that best-fit this data
You will test your routine against MATLABs built-inthe results generated by the two routines should be the same
Print the equations for the 3 sets of coefficients that you have produced
Use linspace to generate more data points along the X-axis
For all 3 sets of best-fit line coefficients:
Use polyval to generate the Y-axis coordinates corresponding to the X coordinates produced in step 7 above
Plot the increased X coordinates (from step 7) and the Y coordinates (from step 8.a above)
Add a legend for all 4 plotted data
Describe what the plots are telling you about this data
Step 5: Create a Best-Fit Coefficients Function
As in past assignments, you are free to implement this function either as:
A subfunction contained in the script M-file for your program
As a function implemented in a separate M-file
You must implement the least squares formula, which generates the coefficients of a 1st degree polynomial that best-fits a given data set. The formula works by minimizing the squares of the differences between each data point and the line that represents all of the data points.
Recall that a 1st degree polynomial has the form:
and the slope-intercept formula for a straight line is the 1st degree polynomial:
The 1st degree least squares formula has two parts:
The formula for calculating the slope:
The formula for calculating the Y-intercept:
where:
and
are vectors of values associated with the X and Y axes, respectively
is the length of the
(or
) vector
All
are
, so
Note that MATLAB supports vectorized versions of all of the required functionality: sum, product, and squaring. Thus, no loops are required anywhere in your implementation.
Your function must (for full credit):
Not use any loops
Generate and return the slope and Y-intercept as a 2-element vector (just like ployfit does). The vector returned must have the slope in out_vec(1) and the Y-intercept in out_vec(2).
Step 6: Output the Polynomials
Example output (note that these are not solutions).
Output for a 1st-degree polynomial will look like this:
y =-9.127x +814.906
And output for a 2nd-degree polynomial:
y =0.913x^2+-632.098x +278554.575
For clarity, each of these equations should be labeled, either on the same line, or just above. Like either of these:
Linear: y =-9.127x +814.906
Quadratic:
y =0.913x^2+-632.098x +278554.575
Step 10: Describe What the Plots Indicate
This is not a data analysis course, so do not worry about whether your answer makes sense or not. You will get credit here for the effort, not for the answer.
I would like you to produce a short statement in a word processed document (using Microsoft Word or Google Docs) describing what you think that the plots are indicating about this data:
Will new course record times be set on the Streif?
If so, when will they be likely to be set?
If not, why not?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!