Creating datetime Arrays
提示1:If you want to specify the time, use the optional fourth through sixth input arguments in the datetime
function. They represent the hour, minute, and second in that order.
t = datetime(2014,5,25,8,11,0) t = 25-May-2014 08:11:00 Note that there are either three or six input values for datetime.)
任务1:
Use numeric inputs to create a datetime
named d
with a value of “February 29th, 2016 17:00”.
解答:
d = datetime(2016,2,29,17,0,0)
提示2:To create vectors and matrices of type datetime
you can specify array inputs to the datetime
function. Notice that providing a row vector as input produces a row vector, and a column vector as input produces a column vector.
任务2:
Create a 3-by-1 column vector named d2
of type datetime as shown below.
01-Feb-1999 01-Feb-2000 01-Feb-2001
解答:
d2 = datetime([1999;2000;2001],2,1)
任务3:
Create a 1-by-4 row vector named d3
of type datetime representing the dates January 1st-4th, 1975.
解答:
d3 = datetime(1975,1,1:4)
任务4:
Create a 12-by-1 vector d4
of type datetime containing the first day of each month in the year 1990.
解答:
d4 = datetime(1990,1:12,1)'
笔记:
(1)创建时间参数最多6个,年-月-日-时-分-秒;
(2)若要创建 datetime 类型的向量和矩阵,可以指定 datetime 函数的数组输入。请注意,提供行向量作为输入会生成行向量,而作为输入的列向量会生成列向量;文章来源:https://www.toymoban.com/news/detail-803028.html
(3)提供列向量的形式可为单个变量写成列向量,例如d2 = datetime([1999;2000;2001],2,1),也可以整体转换为向量,如d4 = datetime(1990,1:12,1)'与d4 = datetime(1990,(1:12)',1))结果是一样的。文章来源地址https://www.toymoban.com/news/detail-803028.html
到了这里,关于MATLAB Fundamentals>>>Creating Datetimes的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!