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

3 ビュー (過去 30 日間)
Torrey Beek
Torrey Beek 2013 年 5 月 13 日
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

回答 (2 件)

Matt Kindig
Matt Kindig 2013 年 5 月 13 日
編集済み: Matt Kindig 2013 年 5 月 13 日
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 2013 年 5 月 13 日

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by