# How to find mean of cells?

조회 수: 69(최근 30일)
Megha 23 Oct 2018
댓글: Megha 23 Oct 2018
I have a cell array 'x' with 1x5 cell class. Now, in x{1,1} has 2x1 cell. Now i would like to find nanmean of (x{1, 1}{1, 1}(5,4)+x{1, 1}{2, 1}(5,4))
Now in xx{1,2} has 4x1 cell. Now i would like to find nanmean of (x{1, 1}{1, 1}(5,4)+x{1, 1}{2, 1}(5,4))
So, In a way it is a nanmean by each elements between two cells.
Can anyone help for this...?

댓글을 달려면 로그인하십시오.

### 답변(1개)

OCDER 23 Oct 2018
You should consider extracting your variables out from cell arrays to simple matrices. Then you can use nanmean. Here are some common functions for extracting data from cell arrays.
cell2mat : cell2mat(C) convert cell to matrix
vertcat : vertcat(C{:}) will concatenate cell into matrix, vertically
horzcat : horzcat(C{:}) will concatenate cell into matrix, horizontally
cellfun : cellfun(@(x) x(1), C) go through each cell element to do something.
Example:
X = {[1,2] [2,3] [3,4]};
X = cell2mat(X(:));
nanmean(X, 2)

#### 댓글 수: 1

Megha 23 Oct 2018
Can you please give example of 2-dimensional matrix?

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!