OBJECTIVES
• To practice structured programming and file I/O operations in MATLAB.
• To learn how to use MATLAB functions to read data files and to generate plots.
• To develop an understanding of regression analysis.
• To learn how to use MATLAB functions for polynomial regression.
GENERAL INSTRUCTIONS
Upon completion of this assignment, you will submit a function m-file and several jpegs of
curve fit plots.
PART 1 - Introductory Exercises
a) Create a script (m-file) A8P1Alastname.m that uses the polyfit, linspace,
polyval and plot functions to create a plot of the data listed below along with a leastsquares line, a 5
th
-degree polynomial and an 8th
-degree polynomial fit. Plot the curves
with 500 data points (use linspace) to produce smooth fit curves. Plot the data with
markers only and solid lines for the fit curves. Add a legend to label the data points and
the three fit curves. Title the plot as follows: “Assignment 8-1a, your name, date and time
stamp”. The date and time stamp must be generated when the program is executed as
was done in previous assignments (use the datestr(now) function). Label the axis (x and
y). Save the figure as A8P1Alastname.jpg
Get Free Quote!
286 Experts Online