필터 지우기
필터 지우기

MATLAB : compare hours (hh:mm:ss)

조회 수: 1 (최근 30일)
Sarah Guiffray
Sarah Guiffray 2015년 7월 27일
편집: Azzi Abdelmalek 2015년 7월 27일
Hello,
I would like to compare hour (not date but just hh:mm:ss). I have different hour and I would like to find a specific hour inside.
Example : x = {'05:05:05', '05:05:06', '05:05:09', '05:05:10'}.
I want to know if y='05:05:06' exist in x, how can I do ?
And I want to know if p='05:05:07' exist and if not, I want to know the nearest hour.
Thank you for your help,

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 27일
편집: Azzi Abdelmalek 2015년 7월 27일
x = {'05:05:05', '05:05:06', '05:05:09', '05:05:10'}
p='05:05:07'
xx=datenum(x)
pp=datenum(p)
[~,idx]=min(abs(xx-pp))
out=x(idx) % the nearest time and idx is its corresponding index

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by