MATLAB: How to convert one date and time from two colums

date timeMATLAB

Im trying to convert the first two columns of a cell into a Matlab time. first column {1,1} is the date in YYYY-MM-DD format and the second it the time in HH:MM format. Any ideas where I'm going wrong?
file = 'D:\Beach Erosion and Recovery\Bournemouth\Bournemouth Tidal Data\tidal_data_jtide.txt'
fileID = fopen(file);
LT_celldata = textscan(fileID,'%D%D%D%D%d%[^\n\r]','delimiter',',');
formattime = 'yyyy-mm-dd HH:MM'
date = LT_celldata{1,1};
time = LT_celldata{1,2};
date_time = datenum('date','time');

Best Answer

Another perturbation of Star's approach...
filename = 'tidal_data_jtide.txt';
TD = readtable(filename); % Read File (used shorter var name--dpb :) )
DT1=datetime(join([string(TD.Var1) string(TD.Var2)])); % first date, time a string; convert to ‘datetime’
DT2=datetime(join([string(TD.Var3) string(TD.Var4)])); % ditto second
units= {'',t.Var7{1},''}; % build cellstr for units
TD=table(DT1,TD.Var5,categorical(TD.Var6), ... % and then make the final table
'VariableNames',{'Time','Height','Tide'});
TD.Properties.VariableUnits={'','TD.Var7,''}; % table() won't accept as named parameter pair
Saved just a short subsection of your input file...built the following from above
> TD
TD =
12×3 table
Time Height Tide
___________________ ______ ____
2017-10-24 01:17:38 1.76 L
2017-10-24 02:57:31 1.92 H
2017-10-24 05:53:35 1 L
2017-10-24 10:45:01 2.06 H
2017-10-24 13:27:16 1.78 L
2017-10-24 15:07:16 1.92 H
2017-10-24 18:12:08 0.98 L
2017-10-24 23:00:16 1.95 H
2017-10-25 01:27:56 1.76 L
2017-10-25 03:28:01 1.97 H
2017-10-25 06:26:41 1.17 L
2017-10-25 10:47:04 1.96 H
>>
From your initial post and observing that the two date/times are consistently one hour apart I didn't include the second in the table as being essentially redundant. If this changes, the fix is obvious.. :)
I also converted the tide indicator variable to categorical.