converting column of datetimes in excel to datenumbers in matlab

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

 Akzeptierte Antwort

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

5 Kommentare

thank you for the response, I am using matlab R2018a and upon trying to run the code above this is what i got
T = readtable('zetdctestdata.xlsx');
T.datetime = cellfun(@(x)datenum(x,'mm/dd/yyyy HH:MM:SS'),T.datetime);
Warning: Usage of DATENUM with empty date character vectors is not supported.
Results may change in future versions.
> In datenum (line 94)
In @(x)datenum(x,'mm/dd/yyyy HH:MM:SS')
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
that is because it's reading the empty row (row 8 in excel) . either delete that from excel or delete it in MATLAB
thank you a lot it has worked
and how do i stop matlab from rounding off the outputs in the columns i get 7.3708e+05 instead of 737076.458333333
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by