matlab的m文件转换成python_将Matlab的datenum格式转换为Python

我刚刚开始从Matlab转到

Python 2.7,我读了我的.mat文件有一些麻烦.时间信息以Matlab的数据格式存储.对于不熟悉的人:

A serial date number represents a calendar date as the number of days that has passed since a fixed base date. In MATLAB, serial date number 1 is January 1, 0000.

MATLAB also uses serial time to represent fractions of days beginning at midnight; for example, 6 p.m. equals 0.75 serial days. So the string ’31-Oct-2003, 6:00 PM’ in MATLAB is date number 731885.75.

(taken from the Matlab documentation)

我想把它转换成Pythons时间格式,我发现了this tutorial.总之,作者说

If you parse this using python’s datetime.fromordinal(731965.04835648148) then the result might look reasonable […]

(在任何进一步的转换之前),这对我来说不起作用,因为datetime.fromordinal期望一个整数:

>>> datetime.fromordinal(731965.04835648148)

Traceback (most recent call last):

File "", line 1, in

TypeError: integer argument expected, got float

虽然我可以围绕日常数据,我实际上需要进口细分时间序列.有人有解决这个问题的办法吗?我想避免重新格式化我的.mat文件,因为它们有很多,同事也需要和他们一起工作.

/ edit(2012-11-01):这在上面发布的教程中已经修复.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值