how do i derived my hourly data from 60 minute data, daily data from 24 hours, and a month from related days?

2 views (last 30 days)
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 Comment
jgg
jgg on 12 Jul 2016
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.

Sign in to comment.

Answers (2)

Milad
Milad on 22 Jul 2016
the forwarded commands can be helpful for making rainfall or runoff data from minute data observed. the commands are helpful but not too professional. results are hourly data and daily data in a proper observed data from start datetime to end datetime without missing data and neglect any time scale in each minute. this example includes 6 months data in each minute. therefore, amount of hour and amount of days are clear. it is recommended to check any codes before using in a small example. remember, the last created file should be used as hourly and daily data. last column is the final result. only last column.
%
% %producing hourly, daily, rainfall or runoff from each minut data
rainfallmin = readtable('dei.xlsx', 'Range', 'A1:B262081');
B = reshape(rainfallmin.Rainfall,[60,4368]);
C = cumsum(B);
Hourly = transpose(C);
%daily
rainfallmin = readtable('dei.xlsx', 'Range', 'A1:B262081');
D = reshape(rainfallmin.Rainfall,[1440,182]);
E = cumsum(D);
daily = transpose(E);

Rupali Wagh
Rupali Wagh on 1 Jul 2019
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!

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!