Strip duration row with time duration 00:00:00:000

2 vues (au cours des 30 derniers jours)
Life is Wonderful
Life is Wonderful le 19 Déc 2019
Hi
I want to remove all rows expect the last with duration 00:00:00:000
Sample out data

Réponse acceptée

Adam Danz
Adam Danz le 19 Déc 2019
Modifié(e) : Adam Danz le 19 Déc 2019
I'm assuming the WeirdDuration data are duration values. This simple solution assumes that you want to eliminate all rows starting at the first row until the last rows that contains a duration of 0.
% T is the table
lastZeroIdx = find(T.WeirdDuration == duration(0,0,0), 1,'last');
T(1:lastZeroIdx-1,:) = []
[update]
if WeirdDuration are not duration values, you can easily modifty the line of code above to use datetime values instead. Example: datetime(0,0,0)
  6 commentaires
Adam Danz
Adam Danz le 20 Déc 2019
If you used the method in my answer as a fix, just keep in mind that it will eliminate all rows of data from row 1 until the last row of 0s no matter what data are between. If you expect your timestamps to be in ascending order starting with 0s, then this simple method should be OK.
Glad I could help with your weird durations ;)
Life is Wonderful
Life is Wonderful le 24 Déc 2019
Modifié(e) : Life is Wonderful le 24 Déc 2019

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Identification dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by