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

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 30 de Sept. de 2020
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

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Sept. de 2020

Comentada:

el 5 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by