www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DateandTimefromVectorsExample.m
%% Date and Time from Vectors % Create a |datetime| array from individual arrays of year, month, and day % values. % Copyright 2015 The MathWorks, Inc. %% % Create sample numeric arrays of year values Y and day values D. In this % case, the month value M is a scalar. Y = [2014;2013;2012]; M = 01; D = [31;30;31]; %% % Create the |datetime| array. t = datetime(Y,M,D) %% % Specify a custom display format for the output, using the |Format| name-value % pair argument. t = datetime(Y,M,D,'Format','eeee, MMMM d, y')