How to calculate Mean of unequal cell arrays?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have results from 44 analyses stored in two cell arrays: 1. DRIFT (the response values) corresponding to INT (intensities). Both are 1*44 cell arrays. For example, the response from 5th analysis is stored in DRIFT{1,5} and the values are corresponding to intensity values in INT{1,5}. I stored the result in cell arrays and not as double because they are of unequal lengths. I want to find the geometric mean of all the 44 responses and plot it. However, as the responses are of different vector lengths (each analysis finish at a different point), I am unable to do so. Could someone help me?
0 comentarios
Respuestas (1)
KSSV
el 30 de Mayo de 2018
% make some random data for demo
N = 10 ;
A = cell(N,1) ;
for i = 1:N
A{i} = rand(randperm(N,1),1) ;
end
%%get mean
N = numel(A) ;
% option 1: use loop
M1 = zeros(N,1) ;
for i = 1:N
M1(i) = mean(A{i}) ;
end
% option 2: use cellfun
M2 = cellfun(@mean,A) ;
2 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!