注册 登录
编程论坛 Matlab

matlab读取excel数据时碰到时间量怎么办?

pinkfly 发布于 2007-11-12 21:04, 15379 次点击

我的excel表格中有一列是时间,
其格式为类似2007-7-7 12:04:56 AM的样式;
我用xlsread读取的时候,其他列的numeric型都能正常读取;
而这一列在matlab中却显示为NaN;我想这个问题很多人都遇到过;
请问我怎么才能得到这些时间数据量,因为这个时间我要根据它作为间段点来对总体数据进行分割的

7 回复
#2
ydgsl2007-11-15 14:54
在excel表中先将时间数值化。
#3
pinkfly2007-11-20 10:05
回复:(ydgsl)在excel表中先将时间数值化。
你是指设置单元格格式么,
我把日期型改为数值型之后,发现不了什么规律啊,
本来是2006-10-1 0:04改后变成了38991
#4
pinkfly2007-11-20 14:20
回复:(pinkfly)回复:(ydgsl)在excel表中先将时间...
matlab的日期-数值转换格式和excel不一样
我用matlab中的datenum函数转化后为732951
#5
pinkfly2007-11-20 14:23
这样吧
我现在能不能把时间这一列读成char型呢?
NaN我实在没办法处理它
#6
pinkfly2007-11-20 14:34
回复:(pinkfly)这样吧我现在能不能把时间这一列读成...
搞定,利用[n,date]=xlsread()即可
#7
huruigege2007-11-21 10:51
用char的格式进行读取肯定可以的。
[n,date]=xlsread()没有尝试过。
#8
huruigege2007-11-21 10:55
[NUMERIC,TXT,RAW]=XLSREAD(FILE,SHEET,RANGE) reads the data specified
in RANGE from the worksheet SHEET, in the Excel file specified in FILE. The
numeric cells in FILE are returned in NUMERIC, the text cells in FILE are
returned in TXT, while the raw, unprocessed cell content is returned in
RAW. It is possible to select the range of data interactively (see Examples
below). Please note that the full functionality of XLSREAD depends on the
ability to start Excel as a COM server from MATLAB.

help中说的很明白,第一个返回的是数值,第二个是文本,第三个是图像。
1