How can I manipulate a matrix based on its elements?

1 vue (au cours des 30 derniers jours)
Arianna K
Arianna K le 2 Oct 2015
Commenté : Arianna K le 16 Oct 2015
So I have a matrix of time values in the form of date/time values from Excel. I subtracted the first element of the vector of dates from each element, which yields elements for the year's worth of dates going from 0 to 365. These numbers are broken into 5 minute time intervals, i.e.,
41709.416666667
41709.420138889
41709.423611111
41709.427083333
41709.430555556
41709.434027778
41709.437500000
41709.440972222
41709.444444444
41709.447916667
41709.451388889
41709.454861111
41709.458333333
41709.461805556
41709.465277778
41709.468750000
41709.472222222
41709.475694444
41709.479166667
And so on. I have a corresponding value associated with each date, an amount. I want to sum up the amounts in the corresponding vector of values for each day, so get 365 sums. I want to be able to sum up those values based on the integer increasing in the date matrix by one, because each day does not necessarily have the same number of measurements. Thus, in the end I want a matrix of 365 dates with 365 sums consisting of the result of adding up the precise number of measurements, taken approximately every 5 minutes each day.
  2 commentaires
Vivek
Vivek le 2 Oct 2015
Happy to try to answer your question - but I do not understand exactly the format your data is in. Are you saying that you have 365 rows worth of data with a different number of observations for each row, and you want to obtain the sum for each row?
Arianna K
Arianna K le 3 Oct 2015
I have thousands of rows of data, but multiple measurements from each day, so only 1 to 365, just with about 200 measurements for each day. I want the sum for each day. Measurements are taken about every 5 minutes and I want the total sum of these values. Thank you so much!

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 2 Oct 2015
Modifié(e) : Matt J le 2 Oct 2015
Sounds like it would be
dailySums = accumarray(Day(:),Val(:))
where Day(i) = 1 to 365 depending on which day the i-th data point is acquired. Likewise, val(i) is the value of the i-th data point.
  9 commentaires
Matt J
Matt J le 16 Oct 2015
Well, again, there is only one place in STREAMWETLAND (line 32) that the problem could be coming from. You haven't given 'dates' in a format that datetime() expects,
Arianna K
Arianna K le 16 Oct 2015
Thank you so much for all your help! I had a few more issues, but I have gotten them all hammered out now, and I have an accurate output document with the daily sums for my data!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time Series Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by