Add least-squares line to scatter plot
h = lsline
lsline superimposes a least-squares line on each scatter plot in the current axes. Scatter plots are produced by the MATLAB® scatter and plot functions. Data points connected with solid, dashed, or dash-dot lines ('-', '--', or '.-') are not considered to be scatter plots by lsline, and are ignored.
h = lsline returns a column vector of handles h to the least-squares lines.
x = 1:10; y1 = x + randn(1,10); scatter(x,y1,25,'b','*') hold on y2 = 2*x + randn(1,10); plot(x,y2,'mo') y3 = 3*x + randn(1,10); plot(x,y3,'rx:') y4 = 4*x + randn(1,10); plot(x,y4,'g+--') lsline