calculation of a mean

2 次查看(过去 30 天)
ShayanA
ShayanA 2018-11-13
评论: ShayanA 2018-11-14
Hi, i have a column with 26668626 rows and 1 column which i will load from an excel file. after i loaded the data wanne have avrage av every 10th row to the end.i wish to put to the new colum.
tried with differet code but the result was not right.
Can someone sopported ?
Thanks Shayan
  3 个评论
ShayanA
ShayanA 2018-11-14
Thanks for you answer and tip. Perhaps i was not to clear with my question but option 2 is what i wanne do.have a avrage of row segment in groups 1 to 10 & 11 to 20 , 21 to 30 and etc
//Shayan
madhan ravi
madhan ravi 2018-11-14
did you see the answer below ? it has exactly what you need

请先登录,再进行评论。

回答(3 个)

dpb
dpb 2018-11-13
26668626 isn't evenly divisible by 10; what do you want to do with the leftover 6 elements? You also can't add a column of 1/10th the length of the rest of the array onto the existing array.
Ignoring those last six,
mnx=reshape(mean(reshape(x(1:fix(length(x)/10)),10,[]),1,[]);
will return a column vector of means of each 10 successive elements, ignoring the last six.
Can append mean of those last onto the end or augment the original array to next multiple of 10 with NaN and use nanmean() instead on the resulting array of 26668630 elements.

Bruno Luong
Bruno Luong 2018-11-14
splitapply(@mean,data,ceil((1:size(data,1))'/10))
  1 个评论
ShayanA
ShayanA 2018-11-14
Hi , and thanks for your support.
Tested right now and its work. . preciated
//Shayan

请先登录,再进行评论。


ShayanA
ShayanA 2018-11-14
Yes i saw it now. Appreciate you support.
//Shayan

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by