Removing Leap day from my timetable

I need to remove leap days of all years from my timetable. I mean all values belong to 29 feb. my timetable is a hourly time table.

1 Commento

That data you attached does not contain a timetable or any kind of datatime data.

Accedi per commentare.

 Risposta accettata

TT is the timetable and TT.Time is the time column.
isLeapDay is a logical vector identiying the rows of TT that belong to a leap day.
isLeapDay = month(TT.Time)==2 & day(TT.Time)==29;
TT(isLeapDay,:) = []; % remove leap days.

8 Commenti

I use this code and get this error:
Unable to use a value of type 'datetime' as an index.
this is a part of my timetable
Adam Danz
Adam Danz il 28 Apr 2020
Modificato: Adam Danz il 28 Apr 2020
Could you show me your code and explain the variables in the code? I'm not using datetime as an index so I suspect there is an implementation error.
I made a timetable:
Data_m = table2timetable(Data,'RowTimes',timeSamples_1);
then change your code to with my table name
isLeapDay = month(Data_m.Time)==2 & day(Data_m.Time)==29;
Data_m(isLeapDay,:) = []; % remove leap days.
after applying i got this error
isLeapDay = month(TT.Time)==2 & day(TT.Time)==29;
I think this creates an index
Yes, that creates an index; not a datetime vector. The error message you shared "Unable to use a value of type 'datetime' as an index." indicates that the error is caused by something else.
I just applied the answer to the data you shared and it works without error.
Please provide the full copy-pasted error message and include the line of code that the error message points to. The error message is not associated with the code from my answer.
Also, what version of Matlab are you using?
Thanks Adam, I applied it in anouther file and it works great.
Sounds like you worked it out! Glad I could help.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by