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

1 次查看(过去 30 天)
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 个评论
dpb
dpb 2019-5-9
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by