Azzera filtri
Azzera filtri

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 visualizzazione (ultimi 30 giorni)
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? %

Risposta accettata

dpb
dpb il 10 Dic 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.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by