what is the format of date variable imported from excel

1 回表示 (過去 30 日間)
xueqi
xueqi 2015 年 6 月 27 日
コメント済み: Peter Perkins 2015 年 7 月 6 日
Hi, I have imported two excels with first column as date and second column as numbers. Then I need to do some manipulation with the two set of data where I am using datenum. Anyway my code is as follows.
% nld=readtable('NLD.xls');
deu=readtable('deu.xls');
corresp = bsxfun( @eq, datenum( nld(:,1) ).',datenum( nld(:,1) )) ;
[r,c] = find( corresp ) ;
And I get the following warning and error message
% Warning: Variable names were modified to make them valid MATLAB identifiers.
> In makeValidName at 25
In @table\private\setVarNames at 48
In table.readXLSFile at 113
In table.readFromFile at 35
In readtable at 118
In readdata at 2
Undefined function 'datetime' for input arguments of type 'cell'.
Error in readdata (line 4)
nld.Date = datetime(nld.Date,'InputFormat','MM/dd/yyyy')
Here is some sample of the imported variable nld
Date x10_Year
____________ ________
'24/06/2015' 1.08
'23/06/2015' 1.1
'22/06/2015' 1.11
'19/06/2015' 1.01
'18/06/2015' 1.04
'17/06/2015' 1.08
'16/06/2015' 1.11
'15/06/2015' 1.09
'12/06/2015' 1.09
'11/06/2015' 1.09
Could you identify what is the problem here? Thanks for your help.
Cheers,
Xueqi
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 27 日
The data are correctly imported, now what is your problem? what do you want to achieve?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 27 日
nlddate = datenum( nld{:,1} );
corresp = bsxfun( @eq, nlddate.', nlddate ) ;
  2 件のコメント
xueqi
xueqi 2015 年 6 月 28 日
Thank you! It works! It seems that we need {} for tables!
Peter Perkins
Peter Perkins 2015 年 7 月 6 日
xueqi, a couple things:
  • You do not need {} for tables, you need {} for cell arrays of strings, which is what you have imported those datetimes in your file as. You will probably be happier specifying a %D format to readtable to read the strings in as datetimes, not as strings.
  • The error you are getting
Undefined function 'datetime' for input arguments of type 'cell'.
indicates that there is something you have not told us.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by