www.gusucode.com > stats 源码程序 matlab案例代码 > stats/PlotALeastSquaresLineExample.m
%% Plot a Least-Squares Line % % Copyright 2015 The MathWorks, Inc. %% % Generate three sets of sample data and plot on the same figure. x = 1:10; rng default; % For reproducibility figure; 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:') %% % Add a least-squares line for each set of sample data. lsline