calculates polynomial regression function
input: x [m x 1 double]: x-values of input data
y [m x 1 double]: y-values of input data
n [1 x 1 double]: order of polynomial regression line
default is set to 1
output: Y [1 x 1 symfun]: regression line as matlab function
R [1 x 1 double]: squared mean mistake
written by Marko Hecht, Karlsruher Institute of Technology, November 2019
I basically only implemented the content of explanation given on this webpage:
The function is not perfect though because I solve the least squares problem by inverting the weighted parameter matrix to multiply it with the y-values to receive the solution. As some parameters may be close to zero, Matlab issues a warning in the command window. Any suggestions as to how to solve this more elegantly are very welcome.
Important: this function is not meant to extrapolate!
Marko Hecht (2019). regressionp (https://www.mathworks.com/matlabcentral/fileexchange/73531-regressionp), MATLAB Central File Exchange. Retrieved .