MATLAB: Excluding date from date and time

date timedatetime

Hello,
I am fascing difficulties with plotting data. My data are containg measurements of heart rate. First column is string with date and time, and second column are values of heart rate. I have converted first column into datetime values using following code:
day89 = datenum(heartrate_89.start_time, 'yyyy-mm-dd HH:MM:SS.FFF');
ts2 = day89;
ts2 = datetime(ts2,'TimeZone','local',…
'ConvertFrom','datenum');
day89=ts2
I have measurements for couple of days and since all of them are staring from 20:00 and last till 10:00, I was wondering if there is a way to plot a graph starting from 20:00 untill 10:00, containing traces for couple of days, because when I try to plot different traces on same graph, since the dates are different, they are far away from each other?
Is there a way to completely exclude date value since I am only interested in time?
Thank you

Best Answer

You can probably also do this with the datetime class, but when you still have your time in the datenum format, you can simply subtract the floor to keep only time.
If you want to keep the traces continuous you can add 1 to values befor 10 AM.
day89 = datenum(heartrate_89.start_time, 'yyyy-mm-dd HH:MM:SS.FFF');
%crop to 1 day
day89 = day89-floor(day89);
L= day89 <= 10/24;
day89(L)=day89(L)+1;
ts2 = day89;
ts2 = datetime(ts2,'TimeZone','local',...
'ConvertFrom','datenum');
day89=ts2