readtable _causing slow operation

Dear all,
Kindly let me know the if there is any option to use any other command instead of readtable to run the attached code.It takes so much of time and please let me know how i can effectively perform reading the data and convert to date num
Attached is the code:
Data=readtable('WMS.xlsx');
testdates = Data{1:end,1};
date_num = datenum(testdates);
date_num2 = datenum(testdates)+table2array(Data(1:end,2))./(24*3600);

댓글 수: 6

Star Strider
Star Strider 2021년 5월 24일
Wiat is the size of ‘'WMS.xlsx'’?
More importantly, what is the reason for using datenum?
NN
NN 2021년 5월 24일
size is 44138.
Using datenum for plotting dates in .fig output
Star Strider
Star Strider 2021년 5월 24일
If the dates are in datetime format, most (not all) plots support them. See Plots that Support Dates and Durations for those details. The MATLAB version is not posted, however simply using datenum with the datetime variable should work to convert it to a date number. No other conversions should be required.
The file is not large, so posting the file (or a representative sample of it — perhaps the first 5 rows — if the data are sensitive) would help.
Walter Roberson
Walter Roberson 2021년 5월 24일
Why are you converting to datenum format?
If you are using the dates for manipulation such as looking up information, or doing seasonal trending, then using datetime() is most often a better choice unless you are passing the dates into existing software that is defined in terms of MATLAB datenum.
If you are using the dates as data for regression purposes, then you would generally pick a base date and time, and subtract that from the input times... which can be done with datetime() objects. Call days() on the resulting duration if you need a numeric relative date.
NN
NN 2021년 5월 24일
Thank you very much for the suggestions.I am attaching the data sample.Please check this and advice.
Hiro Yoshino
Hiro Yoshino 2021년 5월 25일
I often use
This may help you avoid importing unwanted data/variables from your table.

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

답변 (1개)

Walter Roberson
Walter Roberson 2021년 5월 25일

0 개 추천

To read xlsx files, you have two built-in options on Mac and Linux, and one additional option on Windows:
  1. readtable() . For all sufficiently new versions of MATLAB, this invokes internal code in all operating systems, unless you give an option to disable that
  2. xlsread(). For Mac and Linux, this only ever uses internal code. For Windows that has Excel installed, it will attempt to use ActiveX to talk to Excel to do the work, and if that fails then it will use the internal code.
  3. For Windows only, you can use ActiveX or .NET to talk to Excel directly
The other possibilities, not built-in:
  • You can link to an external C or C++ library to do the work for you
  • You can invoke an external process to do the work for you
The same considerations apply for .xls files.
For text files, there would be additional possibilities.

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

질문:

NN
2021년 5월 24일

답변:

2021년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by