I have a monthly time series data in matrix form with 4 columns. I want to sum up always the 3 row elements of the columns. 1-3,3-6,6-9,... ,to get quaterly data. How can I do this in matlab ?

1 vue (au cours des 30 derniers jours)
sum(A(1:3)); sum(A(3:6)); sum(A(6:9)); ... % because I´ve monthly values from 1952-2013 it's impossible to solve all this in the by hand upper way. Does somebody knows, how I can create a function or something else to solve this in a faster way? %

Réponse acceptée

dpb
dpb le 10 Déc 2015
I are complete years, then
reshape(sum(reshape(x,3,[])),numel(x)/(3*size(x,2)),[])
If lacking complete year, operate on the modulo/3 number of rows which do have and have to treat the remainder as special case.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices 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