How to calculate Mean of unequal cell arrays?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
KSSV
il 30 Mag 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) ;
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!