Clear Filters
Clear Filters

How do I adjust this loop to the minute level?

4 views (last 30 days)
So I have part of my code below running through a large Excel sheet of timeseries data to differentiate between average hourly weekend and weekday consumption by pulling the unique hour. I now want to run this again but incorporate the minutes along with the hours. I tried several different ways but to no prevail. Any help would be much appreciated.
for i = 1:length(UniqueTimeSteps)
HourValue(i) = UniqueTimeSteps(i);
[TimeValue,MinValue,Seconds] = hms(UniqueTimeSteps(i));
idx = (t.Hour == TimeValue & weekday(t) > 1 & weekday(t) < 7);
Consumption_Weekday(i) = mean(AptA(idx));
idx = (t.Hour == TimeValue & (weekday(t) == 1 | weekday(t) == 7));
Consumption_Weekend(i) = mean(AptA(idx));
end
  3 Comments
Fatemah Ebrahim
Fatemah Ebrahim on 11 May 2020
The issue I'm having is with the hour and minute, with the code I have now I can do either or but not the two together.
Fatemah Ebrahim
Fatemah Ebrahim on 11 May 2020
I tried running this code:
for i = 1:length(UniqueTimeSteps)
TimeValue(i) = UniqueTimeSteps(i);
[HourValue,MinValue,Seconds] = hms(UniqueTimeSteps(i));
idx = (t.Hour + t.Minute == HourValue & MinValue & weekday(t) > 1 & weekday(t) < 7);
Consumption_Weekday(i) = mean(A(idx));
idx = (t.Hour + t.Minute == HourValue & MinValue & (weekday(t) == 1 | weekday(t) == 7));
Consumption_Weekend(i) = mean(A(idx));
end
figureA = figure;
plot(TimeValue,Consumption_Weekday,'-*b');
hold on
plot(TimeValue,Consumption_Weekend,'--r');

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!