Effacer les filtres
Effacer les filtres

Finding the index in the table with the incomplete input

1 vue (au cours des 30 derniers jours)
uzzi
uzzi le 19 Jan 2023
Commenté : Star Strider le 20 Jan 2023
Hello,
my table has the entry of '2021-09-30 08:58:30.866' but I want to get its index just by finding with '2021-09-30 08:58:30.8'. When I used the find function, I couöldn't get the position of it just by writing '2021-09-30 08:58:30.8'.
Are there anyway to find the index with the incomplete input?

Réponse acceptée

Star Strider
Star Strider le 19 Jan 2023
Are there anyway to find the index with the incomplete input?
Yes. However defining the threshold for the find argument may require a specific definition, since it depends on what the other values are in the vector, and what you are searching for.
Example —
DT = datetime(['2021-09-30 08:58:30.765'; '2021-09-30 08:58:30.866'; '2021-09-30 08:58:30.967'], 'Format','yyyy-MM-dd HH:mm:ss.SSS');
% DTsec = second(DT)
idx = find(second(DT) >= 30.8, 1, 'first')
idx = 2
Result = DT(idx)
Result = datetime
2021-09-30 08:58:30.866
.
  2 commentaires
uzzi
uzzi le 20 Jan 2023
Hello, thank you for your answer. It is very helpful.
Star Strider
Star Strider le 20 Jan 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by