Find indices of matching date times

조회 수: 80 (최근 30일)
Dion Theunissen
Dion Theunissen 2021년 6월 4일
답변: Chidvi Modala 2021년 6월 7일
Hi,
I have 2 tables containing a column datetime. How can I find the first DateTime of table A in table B?
So if Table B contains 20 DateTimes. How can I find the index of the matching datetime from table A?
  댓글 수: 2
Rik
Rik 2021년 6월 4일
Have you tried ismember? It will probably be close to what you need.
Akira Agata
Akira Agata 2021년 6월 4일
Or have you tried withtol function?

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

채택된 답변

Chidvi Modala
Chidvi Modala 2021년 6월 7일
You can refer to the following piece of code
s1 = {'2014-07-28' ; '2014-06-29' ; '2014-07-30'};
s2 = {'2014-08-01' ; '2014-07-30' ; '2014-07-9'};
t1 = datetime(s1,'InputFormat','yyyy-MM-dd')
t2 = datetime(s2,'Format','yyyy-MM-dd')
[logical_Index ,index] = ismember(t2,t1)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by