Single average value for same range of time each day throughout the year
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Eric Beamesderfer
am 8 Jan. 2021
Kommentiert: Eric Beamesderfer
am 8 Jan. 2021
Hello,
I am currently looking for a way to average my dataset for a period of 4 minutes each day. For my current analysis, I am only interested in the specific value at 5pm (17:00:00). Sometimes though, this data point is missing, so I had thought to take an average from 16:58 to 17:02. I had attempted to work through this, using my test Time_Vector (attached) as a reference. My current code unfortunately also returns 16:00:00 - 16:01:59 as well as 17:58:00 - 17:59:59, so at this time I am unable to accurately average my dataset. I would then use the index created to split up my Time_Vector against my y-data to find a specific value each day.
(i.e. Test_Y = Test_Y(mt_id) or Test_Y = Test_Y(Times_to_Keep_id))
H = hour(Time_Vector);
hr_id = H >= 16 & H <= 17;
Time_Vector2 = Time_Vector(hr_id);
mt_id = minute(Time_Vector2) > 58 | minute(Time_Vector2) < 02;
Time_Vector3 = Time_Vector2(mt_id);
% Times_to_Keep_id = hr_id & mt_id;
Thank you for your help.
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 8 Jan. 2021
Bearbeitet: Cris LaPierre
am 8 Jan. 2021
You need to combine your conditions for hours and minutes. Consider using the timeofday function instead.
load Time_Vector
Tind = timeofday(Time_Vector) >= duration(16,58,0) & timeofday(Time_Vector) <= duration(17,02,0);
Time_Vector(Tind,1)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!