Effacer les filtres
Effacer les filtres

How do I adjust this loop to the minute level?

4 vues (au cours des 30 derniers jours)
Fatemah Ebrahim
Fatemah Ebrahim le 11 Mai 2020
Commenté : Fatemah Ebrahim le 11 Mai 2020
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 commentaires
Fatemah Ebrahim
Fatemah Ebrahim le 11 Mai 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 le 11 Mai 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');

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Time Series Events dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by