Mean Value of Cell array having uneven vector

Hi, I have a cell array of dimension mxn, each element of the cell is a vector of 1xp but p is not of same size. I want to create an array of mxp containing the mean value of each element (with index p) across all the cell element (index n). Can someone help me in this regard.
Thank You
Tukaram

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 9월 30일

0 개 추천

An alternative approach
C = {1, [1 2 3]; [2 3], [3 5]};
mp = max(cellfun(@numel, C(:)));
C = cellfun(@(x) {[x nan(1, mp-numel(x))]}, C);
M = cell2mat(arrayfun(@(i) {nanmean(cellfun(@(x) x(i), C), 2)}, 1:mp));
Result
>> M
M =
1.0000 2.0000 3.0000
2.5000 4.0000 NaN

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2020년 9월 30일

댓글:

2020년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by