MATLAB: Convert date and time in seconds

convert

Hello everyone, I have a table with several variables. Among others, I have 2 columns with date and time. These 2 columns are cells with strings ('iscellstr'=1 and 'ischar'=0). How can I convert them in seconds? thank you very much!

Best Answer

Here's a solution with datetime
data=load('matlab.mat')
T=data.T1_B6_09032017;
TimeOfDay=duration(T.time)
Date=datetime(T.date,'inputformat','dd.MM.yyyy')
t=Date+TimeOfDay;
If you really want the output in seconds, here is how you calculate the duration from the first measurement:
ts=seconds(t-t(1));
I suggest you then put the data in a timetable
TT=timetable(t,T);
TT=splitvars(TT);