Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commento
dpb
dpb il 9 Mag 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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by