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

1 visualización (últimos 30 días)
Torrey Beek
Torrey Beek el 13 de Mayo de 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

Respuestas (2)

Matt Kindig
Matt Kindig el 13 de Mayo de 2013
Editada: Matt Kindig el 13 de Mayo de 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 el 13 de Mayo de 2013

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by