Filter löschen
Filter löschen

How do I adjust this loop to the minute level?

4 Ansichten (letzte 30 Tage)
Fatemah Ebrahim
Fatemah Ebrahim am 11 Mai 2020
Kommentiert: Fatemah Ebrahim am 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 Kommentare
Fatemah Ebrahim
Fatemah Ebrahim am 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 am 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');

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Time Series Events finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by