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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (2)

Matt Kindig
Matt Kindig il 13 Mag 2013
Modificato: Matt Kindig il 13 Mag 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 il 13 Mag 2013

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by