How to take Mean of cell array ?

조회 수: 76 (최근 30일)
Joana
Joana 2020년 4월 17일
댓글: Ameer Hamza 2020년 4월 17일
Hi
I have a struct variable A with 1x15 cell, where each cell array is of variable size in it's 1st dimension and other two dimensions are fixed. i.e dimension of 1st cell array is 200x1x120 and of 2nd it is 120x1x120, I want to take the mean of all the cell arrays in variable A How i can do that please.?

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 17일
A_averaged = cellfun(@(x) mean(x, 'all'), A);
  댓글 수: 2
Joana
Joana 2020년 4월 17일
Thanks Ameer for your reply.
What is 'x' in this case.?
Ameer Hamza
Ameer Hamza 2020년 4월 17일
'x' is the variable of anonymous function. This has no effect if there is an x defined in your code. The scope of this 'x' is just inside the anonymous function.
@(x) mean(x, 'all')
cellfun takes each element of cell array A and applies the anonymous function on it.

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

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by