Effacer les filtres
Effacer les filtres

create a matrix where the elements are the sums of the elements of an old matrix

1 vue (au cours des 30 derniers jours)
Hello,
Consider a 100x1 matrix, namely A.
How can I create a new matrix B where
the 1st row of B is the sum of the 1st and 2nd row of A,
the 2nd row of B is the sum of the 3rd and 4th row of A,
the 3rd row of B is the sum of the 5th and 6th row of A,
etc.
Thank you.
Pavlos

Réponse acceptée

Wayne King
Wayne King le 2 Oct 2012
You say matrix in your post, but then you give an example of a column vector (100x1). I'll assume you mean column vector.
A = randn(100,1);
B = filter([1 1],1,A);
B = B(2:2:end);

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by