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

    %% Create Calendar Duration from Year, Month, Day, and Duration Arrays
%%
% Create a 2-by-2 array representing numbers of days.

% Copyright 2015 The MathWorks, Inc.

D = magic(2)
%%
% Create a 2-by-2 |duration| array of hours.
T = hours([1 2; 25 12])
%%
% Create a |calendarDuration| array using scalar values for the year and
% month inputs.
L = calendarDuration(1,13,D,T)
%%
% Month values greater than 12 carry over to years in the display. Hour values greater than 24 do not
% carry over to days in the display, because the number of hours in a calendar day is not necessarily 24 hours.