我经常与 posix 时间(即 unixtime )与其他程序一起工作,但在matlab中,处理时间和日期的最简单格式是Matlab时间序列号格式 .
要从 Unix 转换为 Matlab ,我广泛使用一个小的转换函数:
function matlabtime = unix2matlabtime(unixtime)
%// function matlabtime = unix2matlabtime(unixtime)
%//
%// input : ** unixtime ** : time vector in the UNIX time serial number
%// representation (seconds since 01-jan-1970)
%//
%// output : ** matlabtime ** : time vector in the Matlab time serial number
%// representation (days since 01-jan-0000)
pivot = datenum([1970 01 01 00 00 00]) ;
matlabtime = ( unixtime / 24 / 3600 ) + pivot ;
将此功能保存在路径上的某个位置,您可以如下绘制数据:
%// Generate sample data
sampleunixtime = linspace( 1427205640 , 1427205900 ).' ; %'// ignore this comment
DATA = [sampleunixtime , sin(sampleunixtime./10) ] ;
%// get