MATLAB Answers

converting column of datetimes in excel to datenumbers in matlab

12 views (last 30 days)
Jubilee Sibanda
Jubilee Sibanda on 13 Jul 2020
Edited: Mehmed Saad on 15 Jul 2020 at 10:45
hie everyone
I want to convert data in column C (labeled datetime) of the attached document to a column of date numbers in matlab, which are to be used as input variables for a neural network
please help

  0 Comments

Sign in to comment.

Accepted Answer

Mehmed Saad
Mehmed Saad on 13 Jul 2020
Edited: Mehmed Saad on 13 Jul 2020
T = readtable('zetdctestdata.xlsx');
T.datetime = cellfun(@(x)datenum(x,'mm/dd/yyyy HH:MM:SS'),T.datetime);

  5 Comments

Show 2 older comments
Jubilee Sibanda
Jubilee Sibanda on 14 Jul 2020 at 12:45
and how do i stop matlab from rounding off the outputs in the columns i get 7.3708e+05 instead of 737076.458333333
Mehmed Saad
Mehmed Saad on 15 Jul 2020 at 10:44
Actual value in variable is 737076.458333333 but due to format it is rounding off
The default format for command window is Short
T.datetime(1)
ans =
7.3708e+05
Change Format to long
format Long
T.datetime(1)
ans =
7.370764583333334e+05
But it is just for display purpose

Sign in to comment.

More Answers (0)