bin = discretize(mod(twomonth(:, 1)-7, 24), [7, 11, 16, 22, 23, Inf]-7);
avgprice = splitapply(@mean, twomonth(:, 2), bin);
peakdemand = splitapply(@max, twomonth(:, 3), bin);
result = table({'7-10'; '11-15'; '16-21'; '22'; '23-6'}, avgprice, peakdemand, 'VariableNames', {'period', 'avgprice', 'peakdemand'})
2 Comments
Star Strider (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/478302-how-to-create-an-index-that-keep-tracking-the-hours-in-the-data#comment_740711
Ida 1 (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/478302-how-to-create-an-index-that-keep-tracking-the-hours-in-the-data#comment_740749
Sign in to comment.