在Excel中inputExcel文件
我想用Matlab中的excel文件创build一个包含相关信息的matrix,但是,当我在excel中读取时使用:
data = xlsread(FILENAME);
我的“date”值被转换为NaN
示例inputexcel文件:
- [单元格A1] = 12/20/2010
- [单元格A2] = 2/20/2011
- [单元格A3] = 25
但是,当我读到这个variables使用:
data = xlsread(FILENAME);
我在matrix中的值是:
NaN NaN 25
有没有办法改变这个? 我需要date。
Values in raw: Cell 1 Cell 2 Cell 3 Cell 4 Cell 5 'Date' 'Expiration' 'Strike' 'Implied Vol' 'Days' '01/31/2012' '02/03/2012' 21 .672 3 '02/1/2012' '02/03/2012' 21 .231 2 [...] [...] [..] [...] [...] //1000 more values
从文件中读取原始数据,然后自己parsing:
[~,~,raw] = xlsread('file.xlsx'); dt = datenum(raw(1:2), 'mm/dd/yyyy'); %# serial date number val = raw{3}; %# double value
您现在可以将date格式化为string:
>> datestr(dt) ans = 20-Dec-2010 20-Feb-2011