Taking Mean of Half Values Inside a Cell

Hi,
I have a cell data of 66668x67 size.
I want to take mean of last 30 percent data inside the cell. Like mean of the data starting from row number 46668(might not be the correct row number considering last 30 percent but just for the sake of example) till end for each column.
How can it be done?
If I use a simple mean such as mean(x), it gives me mean of whole data from 1st row till last for each column. (I get a 1x67 result set which is nice for some results) but in some cases I only need to take mean of last 30 percent data inside the cell.

 Accepted Answer

I think you're saying that you have a matrix of values inside a cell in a cell array, but if I misunderstood please correct me (or just provide an example with some random numbers (there's no need for your data to be as big as in your real case, unless you think the number 66668 is especially relevant).
You can specify a subset of a matrix (rows or columns or both) and do anything you want with it (including mean). Here's the mean of the last 30 rows of a matrix in a cell array:
x={rand(100,67)};
mean(x{1}(71:100,:)) % mean of last 30 rows of x{1}
ans = 1×67
0.5318 0.4981 0.4586 0.4908 0.4597 0.5090 0.4404 0.5491 0.4945 0.5527 0.5219 0.5891 0.4909 0.5005 0.5172 0.4613 0.3311 0.6024 0.3985 0.5243 0.4609 0.5137 0.4796 0.5105 0.4920 0.4612 0.5156 0.4447 0.5325 0.6169

1 Comment

Thank you so much!
Yes, you understood it correctly and your example made me understand it and I solved the problem.

Sign in to comment.

More Answers (0)

Products

Release

R2019a

Community Treasure Hunt

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

Start Hunting!