www.gusucode.com > stats 源码程序 matlab案例代码 > stats/AddPopulationAndFittedMeanFunctionsExample.m
%% Add Population and Fitted Mean Functions % Generate data with a polynomial trend. % Copyright 2015 The MathWorks, Inc. p = [1 -2 -1 0]; t = 0:0.1:3; rng default % For reproducibility y = polyval(p,t) + 0.5*randn(size(t)); %% % Plot data and add the population mean function using |refcurve| . plot(t,y,'ro') h = refcurve(p); h.Color = 'r'; %% % Also add the fitted mean function. q = polyfit(t,y,3); refcurve(q) legend('Data','Population Mean','Fitted Mean',... 'Location','NW')