Borrar filtros
Borrar filtros

How to calculate mean value of a column in a table only for certain rows?

1 visualización (últimos 30 días)
BingoIngo
BingoIngo el 9 de Mayo de 2019
Comentada: dpb el 9 de Mayo de 2019
Hello,
I have a table with a lot of rows. In order to determine the mean value of these rows over time, I want to split the table in about 10 parts (1st part would be from 1 to 500k, 2nd part from 500001 to 1000k, etc.). Does anyone know a smart, fast syntax for solving this problem?
(For determining the mean value of the whole column I am currently using meanColumn = mean(MyTable.Column, 'omitnan')).
Many thanks in advance!!
  1 comentario
dpb
dpb el 9 de Mayo de 2019
If it is simply into (roughly) equal parts, just computing a set of indices and looping over them is probably as simple a solution as is...
If the number of rows is precisely divisible by the number of desired groups, there's the "trick" of reshape() to that number of columns and then use mean over the array which computes the means by column.
If there's some other variable by which to group, there's always findgroups and splitapply

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Mathematics 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