[solved] - xlsread on linux read dates as numbers

조회 수: 3 (최근 30일)
yari lazzaro
yari lazzaro 2018년 10월 15일
댓글: yari lazzaro 2018년 10월 16일
Hi, I'm using xlsread to read the content of an .xlsx file
[data,text]=xlsread('MSCIandFX.xlsx','MSCIPI');
it sort of works but it's treating all the dates as numbers. I tried the same on a windows machine and the dates where treated as text and thus appeared under the data variable.
Can someone give their interpretation of what's going on and what's the best way to handle this situation?
edit: for example the date "12/31/1987" is imported in matlab as 32142 which is the same value I see on OpenOffice when converting that same date to text format in the xlsx file. I am attaching the file I'm using
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2018년 10월 15일
This is documented. On Windows with Excel installed, MATLAB uses ActiveX to talk to excel, and has full functionality. Any other configuration is restricted to 'basic' mode.
You have a few choices:
  1. there are routines in the Financial Toolbox or File Exchange to convert the numbers from Excel format to datenum
  2. datetime() with 'convertfrom' excel options
  3. use readtable() instead of xlsread, which in r2014b and later will automatically convert them to datetime objects.
  댓글 수: 1
yari lazzaro
yari lazzaro 2018년 10월 16일
Thank you Walter for pointing that out. The fastest way for me was to directly change the dates in the excel file and convert them to text, I will experiment with readtable() too as you suggested.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by