Here is my excel sample (I reduced the amount of observations a little bit, but this won't affect the final outcome):
DATE TIME DOWN
--------- ---------- -----
1/27/2018 8:00:03 PM 5,375
1/27/2018 8:00:06 PM 5,375
1/27/2018 8:00:10 PM 5,375
1/27/2018 8:00:13 PM 5,375
1/27/2018 8:00:17 PM 5,375
1/27/2018 8:00:20 PM 4,855
1/27/2018 8:00:27 PM 4,855
1/27/2018 8:00:31 PM 4,855
1/27/2018 8:00:35 PM 4,855
1/27/2018 8:00:38 PM 4,855
I usually prefer to use the readtable function together with tweaked import options as follows:
opts = detectImportOptions('data.xlsx');
opts.VariableTypes = {'datetime' 'datetime' 'double'};
data = readtable('data.xlsx',opts);
The data
variable will then be parsed as follows:
DATE (datetime) TIME (datetime) DOWN (double)
---------------------- ---------------------- ----------------
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:03' 5,37500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:06' 5,37500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:10' 5,37500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:13' 5,37500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:17' 5,37500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:20' 4,85500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:27' 4,85500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:31' 4,85500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:35' 4,85500000000000
'27-Jan-2018 00:00:00' '31-Dec-1899 20:00:38' 4,85500000000000
As you can see, when the time is not defined it is defaultized to 00:00:00
; the same goes for the date, which is defaultized to 31-Dec-1899
. Since the reference date is static and never changes, in my opinion the best thing to do is to merge the first two columns of your table in order to produce coherent datenum
values to use as X Data
(datetime
variables cannot be used in the Curve Fitting Toolbox, you have to convert them to serial format):
[y,m,d] = ymd(data.DATE);
[h,mn,s] = hms(data.TIME);
x = datenum(y,m,d,h,mn,s)
x =
737087.833368056
737087.833402778
737087.833449074
737087.833483796
737087.833530093
737087.833564815
737087.833645833
737087.83369213
737087.833738426
737087.833773148
The values to be used as Y Data
in the cftool
can instead be extracted directly from the data
column DOWN
:
y = data.DOWN;