How to convert from matlab time to reall time and date

5 visualizzazioni (ultimi 30 giorni)
I have
datestr(7.3684e+05)
ans =
'25-May-2017'
But I need the time and seconds aswell, How do I get this ?
whith this information - I am trying to combine this with [x y]=ginput, as I want to take the times off a graph.
I have tried using
datetick('x', 'dd/mm - HH:MM', 'keepticks', 'keeplimits'); and datetick('x')
Any advise would be appreciated as I am not following the help pages for this problem

Risposta accettata

Stephan
Stephan il 26 Nov 2018
Modificato: Stephan il 26 Nov 2018
datestr(7.3684e+05,'dd-mmmm-yyyy HH:MM:SS')
ans =
'25-May-2017 00:00:00'
or with some content in it:
>> datestr(7.3684e+05+13.42,'dd-mmmm-yyyy HH:MM:SS')
ans =
'07-June-2017 10:04:48'
Best regards
Stephan
  4 Commenti
Rebecca Ellis
Rebecca Ellis il 26 Nov 2018
I am getting :
'15-Oct-4034 01:40:08'
'15-Oct-4034 13:40:38'
'15-Oct-4034 01:59:33'
'15-Oct-4034 13:47:54'
But they should be all 23rd/24th of may 2017
When I follow:
% t1 = datetime('23-May-2017 09:15:00');
%change format to :
t1 = datetime('2017-05-23 09:15:00');
% Get 5 Points
[x,y] = ginput(4);
% Calculate the picked dates with time
date_x = x(:)+t1;
Rebecca Ellis
Rebecca Ellis il 26 Nov 2018
time = datestr(x)
time =
4×20 char array
'23-May-2017 16:25:08'
'24-May-2017 04:25:38'
'23-May-2017 16:44:33'
'24-May-2017 04:32:54'
And it seemed to have worked, thank you for helping me get to here. much appreciated.

Accedi per commentare.

Più risposte (1)

Peter Perkins
Peter Perkins il 27 Nov 2018
Rebecca, your description is not clear enough to understand what you are trying to do, but unless you are using a fairly old version of MATLAB, you should try to stay away from the old datenum/datestr functions and use datetime instead.

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by