MATLAB: Fitting a lines to a scatter plot

suggestions

Hello,
I am taking a course with a ton of data analysis. I switched over to Engineering Equation Solver just because of the graphing capabilities, however I am not liking the limited options of using an array. The only reason I switched is because I am not too comfortable with plotting data and then fitting a line. Last data analysis assignment I had a lot of problems plotting lines on a scatter plot. What I am going to do now is take the array I have in EES and compress it to a matrix in Matlab.
Can someone explain to me how to fit a variety of trends to a scatter of data?

Best Answer

Fit = polyfit(x,y,1); % x = x data, y = y data, 1 = order of the polynomial i.e a straight line
plot(polyval(Fit,x))