Dividing set of data into groups and evaluating the mean of each group
2 次查看(过去 30 天)
显示 更早的评论
Hi. Can any body help me with the following please?. I have a set of random data like x=[-3,-10,-2,...,-7] which is up to let say 5000 values. I need to divide x into set of groups x1, x2, x3, ...,xn, where each group of x has 50 elements. Then I need to evaluate the mean of each group and compare it with the mean of the next group. Thank you in advanced.
0 个评论
回答(3 个)
Akira Agata
2018-2-13
Another way:
x = rand(5000,1);
g = repelem(1:100,50)';
avg = splitapply(@mean,x,g);
Image Analyst
2018-2-13
I'm not sure how you're defining/selecting the values to go into each group, but once you have the groups defined, then you can use grpstats() if you have the Statistics and Machine Learning Toolbox.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!