Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab omiting milliseconds from datenum

Tags:

matlab

Let

x=7.369030000162731e+05

x is a matlab date and it is equal to

27.07.2017 00:00:01.406

I want to remove the milliseconds from it (ie. .406)

To do this I convert it to datestr with 'dd.mm.yyyy HH:MM:SS' format and then again to datenum

datenum(datestr(x,'dd.mm.yyyy HH:MM:SS'))

Is there a simpler way to do this.

like image 514
Sharek Avatar asked Jan 19 '26 18:01

Sharek


1 Answers

If you want the manual approach:

y = floor(x*86400)/86400;

because serial date numbers are measured in days, and 86400 is the number of seconds in a day.

like image 199
Luis Mendo Avatar answered Jan 22 '26 22:01

Luis Mendo