www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/PlotTimeSeriesObjectWithSpecifiedStartDateExample.m

    %% Plot Time Series Object with Specified Start Date
% Create a time series object, set the start date, and then plot the time
% vector relative to the start date.

% Copyright 2015 The MathWorks, Inc.

x = [2 5 8 2 11 3 6];
ts1 = timeseries(x,1:7);

ts1.Name = 'Daily Count';
ts1.TimeInfo.Units = 'days';
ts1.TimeInfo.StartDate = '01-Jan-2011';     % Set start date.
ts1.TimeInfo.Format = 'mmm dd, yy';       % Set format for display on x-axis.

ts1.Time = ts1.Time - ts1.Time(1);        % Express time relative to the start date.

plot(ts1)