How to convert from matlab time to reall time and date

2 ビュー (過去 30 日間)
Rebecca Ellis
Rebecca Ellis 2018 年 11 月 26 日
回答済み: Peter Perkins 2018 年 11 月 27 日
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

採用された回答

Stephan
Stephan 2018 年 11 月 26 日
編集済み: Stephan 2018 年 11 月 26 日
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 件のコメント
Rebecca Ellis
Rebecca Ellis 2018 年 11 月 26 日
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 2018 年 11 月 26 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2018 年 11 月 27 日
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.

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by