Effacer les filtres
Effacer les filtres

How to a partition a data set of days into weekdays and weekends

1 vue (au cours des 30 derniers jours)
Torrey Beek
Torrey Beek le 13 Mai 2013
Hi,
I'm excited to use this site; the previous posts have been immeasurably helpful for me in understanding how to use MATLAB.
I have a data set consisting of active and reactive power measurements for 365 days (1 April 2009 to 30 March 2010), beginning on a Wednesday. The exact dimension of the array is 365x48 (365 days of the year, 48 half-hours). I need to partition the data set into weekdays and weekends, and was wondering if someone could help me understand how this can be done using a MATLAB script?
Ideally I would like to sort the data set into a collection of weekdays in one array, and weekends in a separate array. Any ideas?
Thanks in advance, Torrey

Réponses (2)

Matt Kindig
Matt Kindig le 13 Mai 2013
Modifié(e) : Matt Kindig le 13 Mai 2013
Hi Torrey,
I think this should do it:
%Matrix is your 365x48 matrix
%Every 4th and 5th rows are Saturday and Sunday
weekend_indices = sort([4:7:365, 5:7:365]);
weekday_indices = setdiff(1:365, weekend_indices);
Weekdays = Matrix(weekday_indices,:);
Weekends = Matrix(weekend_indices,:);

Sean de Wolski
Sean de Wolski le 13 Mai 2013

Catégories

En savoir plus sur Shifting and Sorting Matrices 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