Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将日期和时间转换为数值。例如:
>> num = datenum('2011-05-07 11:52:23') num = 7.3463e+05
在不手动输入日期和时间的情况下,我将如何编写脚本来为众多值执行此操作?
您可以先将日期字符串存储在单元格数组(或矩阵,前提是它们具有固定格式)中,然后将其直接提供给datenum. 例如:
datenum
C = {'2011-05-07 11:52:23' '2011-03-01 20:30:01'}; vals = datenum(C)