Find indices of matching date times

79 visualizaciones (últimos 30 días)
Dion Theunissen
Dion Theunissen el 4 de Jun. de 2021
Respondida: Chidvi Modala el 7 de Jun. de 2021
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 comentarios
Rik
Rik el 4 de Jun. de 2021
Have you tried ismember? It will probably be close to what you need.
Akira Agata
Akira Agata el 4 de Jun. de 2021
Or have you tried withtol function?

Iniciar sesión para comentar.

Respuesta aceptada

Chidvi Modala
Chidvi Modala el 7 de Jun. de 2021
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)

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by