Grouping In Pairs the Coefficients of an Array and Computing the Average of each group

1 visualización (últimos 30 días)
Hello,
I have an array with even number of elements and i need to group its coefficients in pairs.
After that i want to compute the average of each group.
I would like some help!
Here is an example:
Given Array: A=[88 88 89 90 92 94 96 97]
Output :AG=[88 88] [89 90] [92 94] [96 97]
Thanks,

Respuesta aceptada

Alan Stevens
Alan Stevens el 25 de Nov. de 2020
Use reshape to get the pairs in two rows.
AG = reshape(A,2,4);
Then the average of each group is simply
Agav = mean(AG);

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by