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

    %% Differences Using Specific Calendar Components
% Create a |datetime| array and then compute the differences between the values in terms of days.
%%

% Copyright 2015 The MathWorks, Inc.

t = datetime('now') + calmonths(0:3)
%%
D = caldiff(t,'days')
%%
% Computer the differences between the datetime values in terms of weeks
% and days.
D = caldiff(t,{'weeks','days'})