MATLAB: A better explanation of polyfit please

polyfit

My teacher wants us to use polyfit and gave us a little bit of information on how to use it, but what he gave us makes no sense and I've looked on this website for an explanation and that didn't help me. I know that the form is polyfit(x,y,n) but I'm not sure what the n stands for or how to figure it out from a set of data. Thanks in advance.

Best Answer

  • The ā€˜nā€™ is the degree of the polynomial. The degree can be considered to be the highest power of the independent variable, x. So a first-degree polynomial is p(1)*x + p(2), a second-degree p(1)*x^2 + p(2)*x + p(3), and so forth.