필터 지우기
필터 지우기

Mean of each Value in a Cell Array

조회 수: 1 (최근 30일)
Fabio Taccaliti
Fabio Taccaliti 2022년 7월 8일
댓글: Voss 2022년 7월 8일
Hello,
I havea cell A (107x3), with each 14x8 double.
I want to create a cell A_mean 1x3 that just contain three 14x8 doubles, that are the mean of all the value.
I mean, A_mean{1,1}(1,1) should be the mean(A{1,1}(1,1),A{2,1}(1,1)...A{107,1}(1,1)), and the same for all the others numbers.
I really don't know how can I do it..
Thanks in advance :)

채택된 답변

Voss
Voss 2022년 7월 8일
% a cell A (107x3), with each 14x8 double
A = arrayfun(@(~)randn(14,8),zeros(107,3),'UniformOutput',false)
A = 107×3 cell array
{14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double} {14×8 double}
% I want to create a cell A_mean 1x3 that just contain three
% 14x8 doubles, that are the mean of all the value
N = size(A,2);
A_mean = cell(1,N);
for ii = 1:N
A_mean{ii} = mean(cat(3,A{:,ii}),3);
end
disp(A_mean);
{14×8 double} {14×8 double} {14×8 double}
  댓글 수: 4
Fabio Taccaliti
Fabio Taccaliti 2022년 7월 8일
Ohh you are right!! Thanks a lot for the help!
Voss
Voss 2022년 7월 8일
You're welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by