Question: Task 2 ( 1 7 points ) A student collected data from a tensile testing experiment ( load in Newtons as a function of time

Task 2(17 points)
A student collected data from a tensile testing experiment (load in Newtons as a function of time in
seconds), but there was electronic noise in the load cell used to record the data. The recorded data is
available in noisy 2.x lsx.
The student needs to smooth the data using a least-squares approach. In this case, there is a polynomial
relationship between x and y values, but it is clear that the relationship is not linear.
Week 15 Assignment
Introduction to Structured Programming (MAE 1090)
Due Sunday, May 5,11:59 pm (for all sections)
The built-in MATLAB function, polyfit, will determine values of vector p that will fit a polynomial of a
specified order using a least-squares approach to data given as x and y vectors, where the general form
of a polynomial of order n approximating the data is:
p1xn+p2xn-1+cdots+pnx+pn+1
Once p has been determined, a vector y** can be determined, which gives the values of y approximated
using an nth order polynomial, using the built-in MATLAB function, polyval.
For instance, a 5th order polynomial is given as: y**=p1x5+p2x4+p3x3+p4x2+p5x+p6.
(See the MATLAB help for polyfit and polyval.)
Write MATLAB code to approximate the data for the student, as described below.
Include comments explaining your code.
The main function should call a subfunction to read the data (using readtable) from the provided
spreadsheet file.
The main function should call a second subfunction to approximate the data using polynomials of
orders 3-6(using polyfit and polyval).
Output a plot containing the original data plotted with black circles with a marker size of 15 and a
linewidth of 2. Superimpose plots of the approximated load values for polynomials of order 3-6
using lines with a linewidth of 4 and different colors for each polynomial order. Set the x and y axes
limits so that data points are not located on the edge of the plot. Create a legend with labels for
the original data and the approximated values, specifying the polynomial order for each color line.
Label the x and y axes appropriately (include units).(Make sure the legend is positioned where it
doesn't cover any data.)
For extra credit, create a second plot showing the errors associated with each polynomial. (Plot
the values of (y**-y) vs.x.) Use dots of different colors for each polynomial (matching the colors
for polynomial order in the first plot). The plot symbols should have a marker size of 20. Provide
appropriate labels for the x and y axes, create a legend with labels for polynomial order, and include
an appropriate plot title with a fontsize of 14.).(Make sure the legend is positioned where it doesn't
cover any data.)
Task 2 ( 1 7 points ) A student collected data

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!