Uploaded by Elliott Ford

Curve fitting coding problem set

advertisement
Data Modeling and Regression Analysis with MATLAB
In this assignment, you will use MATLAB to perform data modeling and regression analysis on
a given dataset. You will apply two different approaches for regression analysis: polynomial
regression using the polyfit function and the regress function.
The following dataset is given to you:
X
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Y
3.4
4.2
6.1
8.0
10.3
12.9
15.5
17.7
20.2
22.8
25.1
27.3
30.2
32.6
35.4
37.9
40.1
42.7
45.2
48.0
1- Plot a scatter plot of the data points to visualize the relationship between the independent
variable (X) and the dependent variable (Y).
2- Perform polynomial regression using the polyfit function to fit a polynomial model to the
data. Experiment with different polynomial degrees (1st, 2nd, 3rd, and 4th degree) and
determine the degree that provides the best fit. Plot the polynomial regression curves
along with the scatter plot of the data.
3- Calculate the coefficients of the polynomial model and display them in the command
window.
4- Redo part 2 using the regress function.
Download