Importing from Excel dropping first column

17 ビュー (過去 30 日間)
Tristan
Tristan 2014 年 10 月 23 日
コメント済み: Image Analyst 2014 年 10 月 23 日
Hi everyone,
I have some code that imports time series data from Excel into MATLAB on my Mac laptop using xlsread. When I send the code to my advisor and he runs it on his PC, he runs into significant problems because his MATLAB seems to skip the date column, so the first column of the imported document is the second column of the Excel file. It occurs to me that this must be a compatibility issue, but I cannot find a quick fix anywhere. Thoughts?
Thanks in advance.

採用された回答

Image Analyst
Image Analyst 2014 年 10 月 23 日
You forgot to attach the file. Change the numbers and text if you need to anonymize it, but it's the only way we can try it. Does he see all columns if he opens it in Excel rather than MATLAB? Is the data in a table format (columns of data with a row for column headers)? Can you use readtable() instead of xlsread()?
t = readtable(excelFullFileName);
  2 件のコメント
Tristan
Tristan 2014 年 10 月 23 日
Sorry for forgetting to attach. I figured out the problem. I had to convert the Excel dates to numeric format. xlsread was not treating them as numeric, and hence skipping them. Thanks for your help!
Image Analyst
Image Analyst 2014 年 10 月 23 日
Ah, you were just doing
numbers = xlsread(filename);
I almost never do that. Usually I want the raw cell array like you get by doing
[numbers, strings, raw] = xlsread(filename);
The usual reason I do this is that the rows and columns for numbers and strings is out of sync. A certain row, column specified for numbers and strings does not refer to the same cell in Excel, whereas it does with raw. But in your situation, you could get the dates in the non-numeric format (whatever that is) by using the third return argument of xlsread() and shouldn't have to worry about converting format in Excel prior to importation.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by