필터 지우기
필터 지우기

Convert number to time

조회 수: 6 (최근 30일)
Linus Dock
Linus Dock 2016년 2월 18일
답변: Jan 2016년 2월 18일
Hi, is there a way to convert numbers in the format 0000 to time in the format HH:MM in matlab 2014a? Is there also a way to add this time to a vector with only dates but no specified time?
Thank you!
  댓글 수: 2
Stephen23
Stephen23 2016년 2월 18일
What exactly is "the format 0000"? Is this a string of digits? What do the digits represent?
Jan
Jan 2016년 2월 18일
And waht exactly is "a vector with only dates"?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2016년 2월 18일
Perhaps you have something like this:
Date = {'10-May-2015', '11-Mar-2016'}
Time = [1234, 2345]; % In the meaning of: 12:34 and 23:45
Then:
TimeC = sprintfc('%02d:%02d', floor(Time / 100), rem(Time, 100));
DateAndTime = strcat(Date, TimeC);
Unfortunately printfc is not documented. So please write a message to the support team, that you want this function to be supported officially. Until then use:
C = cell(size(Time));
for iC = 1:numel(C)
C{iC} = sprintf('%02d:%02d', floor(Time(iC) / 100), rem(Time(iC), 100));
end
But this is a bold guess only. Perhaps you have different input types.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by