This is an example of how to do a linear fit. Note that it uses the three-argument output form of polyfit to avoid numerical problems with the time vector.
t = time1155; d = data1155(:); % Only use that last 30 day's worth of data keep = t>(now-30); t = t(keep); d = d(keep); [p,S,mu] = polyfit(t,d,1); % p1 is the equation for the linear fit to the data p1 = [p(1)/mu(2) p(2)-p(1)*mu(1)/mu(2)]; tf = [t(1) t(end)]; df = polyval(p1,tf); plot(t,d,'o:') hold on plot(tf,df) datetick
data points
Created 19 Oct 2011 by Ned Gulley
244 views (30 days)
This trend is associated in this plot (though may not be used.)
0 comments