In MATLAB, when you plot something, there's a tool available which is called "curve fitting". And if you have a set of data points and a linear correlation, this tool will easily come up with an equation on the form y = ax + c.
I want to do exactly that, but I need to do it programmatically. I know that I can use
polyfit to find the coefficient, and
polyval to evaluate as many data points as I want, but what I can't figure out is how to find the constant c. This is very important, since I need to be able to plot the line as well next to my data points.