www.gusucode.com > econ 案例源码程序 matlab代码 > econ/OverlayRecessionBandsExample.m
%% Overlay Recession Bands % Overlay recession bands on a plot of multiple time series. % Copyright 2015 The MathWorks, Inc. %% % Load data on credit defaults, and extract the predictor variables in the % first four columns. load Data_CreditDefaults X0 = Data(:,1:4); T0 = size(X0,1); %% % Convert the dates to serial date numbers, as required by |recessionplot|. dates = datenum([dates,ones(T0,2)]); %% % Create a time series plot of the four credit default predictors. figure; plot(dates,X0,'LineWidth',2); h = gca; h.XTick = dates(1:2:end); datetick('x','yyyy','keepticks') xlabel 'Year'; ylabel 'Level'; axis tight; %% % Overlay recession bands corresponding to U.S. recessions reported by the % National Bureau of Economic Research. recessionplot %% % The plots shows that two recessions occurred within the range of the time % series.