Clear Filters
Clear Filters

Manipulate time series matrix

2 views (last 30 days)
Danilo M
Danilo M on 18 Aug 2016
Edited: Azzi Abdelmalek on 18 Aug 2016
I have a time series matrix like this:
Yr Month Day Hour Min Precipitation-rate
1997 01 01 00 00 0.5
1997 01 01 00 15 0.2
1997 01 01 00 30 0.0
1997 01 01 00 45 0.0
1997 01 01 01 00 0.0
1997 01 01 01 15 0.0
1997 01 01 01 30 0.1
1997 01 01 01 45 0.3
1997 01 01 02 00 0.5
I need hourly data, so I want to sum precipitation values for each full hour, getting this:
1997 01 01 00 00 0.7
1997 01 01 01 00 0.4
There's a practical way to do that on Matlab?
Tks

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 18 Aug 2016
M=[1997 01 01 00 00 0.5
1997 01 01 00 15 0.2
1997 01 01 00 30 0.0
1997 01 01 00 45 0.0
1997 01 01 01 00 0.0
1997 01 01 01 15 0.0
1997 01 01 01 30 0.1
1997 01 01 01 45 0.3
1997 01 01 02 00 0.5]
[ii,jj,kk]=unique(M(:,1:4),'rows')
out=[ii accumarray(kk,M(:,6))]

Community Treasure Hunt

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

Start Hunting!