NaN result from xlsread

16 ビュー (過去 30 日間)
Carl
Carl 2012 年 5 月 22 日
コメント済み: Soumojit Shee 2019 年 5 月 16 日
I have a (large) excel file in which the first column is dates and the following 48 columns contain numerical data. I am reading the data using the command:
[fcp_mat,fcp_date]=xlsread('FCPWF.xlsx','a3:AW300000');
This results in fcp_date being an array of cells each containing a string of the date which is fine.
Fcp_date however sometimes has 48 columns and sometimes 49. When it contains 49 the first column is NaN, it is clearly putting the dates into the numerical variable. I suspect the problem is due to a corrupted input file but am not sure exactly what to check. If there is a single cell in the first column containing a number (eg if the date has been formatted at an excel number) would this cause the whole column to be read with the others as NaN? What about if there is a blank cell or a cell containing ‘’?
  1 件のコメント
Soumojit Shee
Soumojit Shee 2019 年 5 月 16 日
'format long' solved the same in my code.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 22 日
Add the third output parameter ("raw") to the xlsread(), and examine that for the rows that are having problems.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by