www.gusucode.com > stats 源码程序 matlab案例代码 > stats/AddAReferenceLineAtTheMeanExample.m
%% Add a Reference Line at the Mean % Generate sample data for independent variable |x| and a dependent variable % |y| . % Copyright 2015 The MathWorks, Inc. x = 1:10; y = x + randn(1,10); %% % Create a scatter plot of |x| and |y| . scatter(x,y,25,'b','*') %% % Superimpose a least-squares line on the scatter plot. lsline %% % Add a reference line at the mean of the scatter and its least-squares % line. mu = mean(y); hline = refline([0 mu]); hline.Color = 'r'; %% % The red line shows the reference line at the mean of data.