Fit a polynomial to a sample data set, and estimate the 95% prediction intervals and the roots of the fitted polynomial. Plot the data and the estimations, and display the fitted polynomial expression.
Generate sample data points (x,y) with a quadratic trend.
Fit a second-degree polynomial to the data by using the polyfit function.
Estimate the 95% prediction intervals by using polyconf.
Plot the data, fitted polynomial, and prediction intervals, and display the fitted polynomial expression.
Find the roots of the polynomial p.
Because the roots are real values, you can plot them as well. Estimate the fitted values and prediction intervals for the x interval that includes the roots. Then, plot the roots and the estimations.
Alternatively, you can use the Polynomial Fitting Tool function for interactive polynomial fitting.