www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/AddDaystoaSerialDateNumberExample.m
%% Add Days to a Serial Date Number % This example shows how to add a rational number of days to a serial date % number. % Copyright 2015 The MathWorks, Inc. %% % The |now| function returns the current date in serial date number format. % You can add a number to this date. For this example, add 50 days. futuredate = now+50 %% % Alternatively, the initial date might be in date string format. Convert % the date to a serial date number using the |datenum| function. initialdate = datenum('21.03.2012 13:15','dd.mm.yyyy HH:MM'); %% % Add a rational number of dates to the initial date. In this example, add % 5.5 days. futuredate = initialdate + 5.5 %% % You can convert the future date to date string format. datestr(futuredate,'dd.mm.yyyy HH:MM')