How to convert from matlab time to reall time and date

조회 수: 5 (최근 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 CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by