Selecting Mondays from a Timetable or Table using the datetime object

1 vue (au cours des 30 derniers jours)
Lewis Waswa
Lewis Waswa le 8 Mar 2022
Commenté : Stephen23 le 8 Mar 2022
Hi,
I would like to write a script that scrolls through my five minutes resolved timetable / table to select identifies all the days that are Mondays and then group them based on the datetime variable of the table/timetable.
I have tried several other ways to do it including the one below. Instead, if I specify the the day as 1, it returns all the first days of the periods (in this case months) and not specifically the Mondays.
Day1=HHB1(1==day(HHB1.VarName1),:); % HHB1 is the datetime object
%%
Any help?

Réponse acceptée

Stephen23
Stephen23 le 8 Mar 2022
Modifié(e) : Stephen23 le 8 Mar 2022
By default DAY returns the day of the month, so you need to specify its second argument like this:
d = day(t,'dayofweek')
  4 commentaires
Lewis Waswa
Lewis Waswa le 8 Mar 2022
Thank you @Stephen. This returns the data I need.
Stephen23
Stephen23 le 8 Mar 2022
@Lewis Waswa: Please remember to click the accept button if my answer helped you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by