how do i derived my hourly data from 60 minute data, daily data from 24 hours, and a month from related days?
1 次查看(过去 30 天)
显示 更早的评论
I attached a file include data in May in each minute, hour and day to show clearly. data are for May as sample. my data is in minute each month. it means i don't have hourly and daily and monthly data. consider if I work in a year how much is hard to make hourly and daily data in excel. impossible. I need to make my hourly and daily and finally monthly data while I have for each minute data.
It means that we have each minute data. i would make them hourly time scale. for example in 1 am, 1-5-2016 we have 60 minutes. so I should sum all 60 minutes only for 1 am. then next 60 minutes is for 2 am, so I should sum only 60 minutes for 2 am to see what is sum of data for 2 am and go on. it is clear that finally i have hourly data derived from correspond minutes. this situation will repeat for transfering data from hour to day, it means 1-5-2016 has 24 hours which I need sum of my data only in 1-5-2016. clearly, 24 hours in 1-5-2016 will sum and show a value for only 1-5-2016. then, 2-5-2016 has own value based on the correspond 24 hours (or 1440 minutes in 2-5-2016 ). finally I have 31 values for may as days. finally, May has 31 days, and I need to have sum of my data for May which is a value. it shows a value for whole May. Note, maybe this info can be helpful to reduce the error for time format in Matlab. 1 hour = 60 min 1 day= 1440 min 1 month = 44640 min ( May is 31 days,) maybe I can have a simple script to do for every month, or I can adjust some small part of command for a yearly data. attached excel file also helpful to show the meaning the process. Thanks.
1 个评论
jgg
2016-7-12
You have time-stamps minute by minute, so you can convert it into a datetime object, then extract the relevant parts:
date = '2016-06-01 1:00:00';
t = datetime(date);
d = day(t);
y = year(t);
Then just do a conditional sum to get the values you want. For example, if you have a vector of rainfalls r of the same size as t then just do sum(r(day(t) == 1)) to get the sum of all rainfall on that day.
As an aside, you can do this in Excel directly; they have similar time functions and a conditional sum function.
回答(2 个)
Rupali Wagh
2019-7-1
have you god your solution , i have same problem , but i want a energy consumption data in the above mentioned form ,for this i want a matlab code ,please help
i attached my .csv file which contains enery consumption values
thanks in advance!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!