Single average value for same range of time each day throughout the year
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Eric Beamesderfer
el 8 de En. de 2021
Comentada: Eric Beamesderfer
el 8 de En. de 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 comentarios
Respuesta aceptada
Cris LaPierre
el 8 de En. de 2021
Editada: Cris LaPierre
el 8 de En. de 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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!