Question: Please solve the following question using Matlab Language. When it refers to X & Y I think it it is reffering to s etting up
Please solve the following question using Matlab Language.
When it refers to X & Y I think it it is reffering to setting up XA=Y and taking A = X\Y. I can't post the .mat file, but you can still create the code without it. Thanks!

Homework Problem 2: Polynomial Regression In the previous problem, you fitted a line to a given data in the x-y plane. However, from graphical visualization, you must have observed this to be a crude fit. In this problem, you are going to use a polynomial to fit the data Create a function polyRegression which takes in three input arguments xdata, ydata and p the degree of the polynomial. Note that xdata and ydata are stored as nxl column vectors You should return three output arguments - cStar, a (p+1) x 1 column array which corresponds to the coefficients of the polynomial fitted, err which is calculated using the MATLAB command norm(XA-Y,2) where X and Y are as discussed in lecture, and flag which should be assigned to be 1 if everything works out okay, or -1 in case of an error In case of an error, you must return cStar to be empty and err to be Inf. Errors should be detected for two cases: if the sizes of xdata and ydata do not match, or if the number of coefficients of the polynomial are more than the no of input data points. You should test your function with the data provided in problem2data.mat. You should be able to reproduce the following result. > [cStar , err,flag] -polyRegression (xdata, ydata ,4) ?. 9364 1.0261 -11.3279 32.6086 32.9614 err 1.2742 Store the code of this problem in the filename polyRegression.m. This file must go into your zipped fo lder as it will be evaluated
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
