在matlab中获取当前日期和时间的函数的具体应用如下:
一、date now clock
1.date:按照日期字符串格式返回当前系统日期;
2.now:按照连续的日期数值格式返回当前系统时间;
3.clock:按照日期向量格式返回当前系统时间。
>> date
ans =
21-Apr-2014
>> now
ans =
7.3571e+05
>> clock
ans =
1.0e+03 *
2.0140 0.0040 0.0210 0.0130 0.0050 0.0235
二、year month day hour minute second
matlab中分别使用year,month,day,hour,minute,second从上面讲到的字符串和连续型日期时间格式中提取年月日时分秒等信息。
>> year(date)
ans =
2014
>> year(now)
ans =
2014
>> year(clock)
ans =
5 0 0 0 0 0
注意:上面的函数是没法从向量型日期时间格式中正确读取上述信息的。
注:转自http://blog.sina.com.cn/s/blog_50cfd0fc0100r3g0.html