Finding mean of data in array inside another array

3 vues (au cours des 30 derniers jours)
Yat Chi
Yat Chi le 12 Déc 2023
Commenté : Yat Chi le 12 Déc 2023
I copied data into a new variable called X, inwhich inside X there are 1851x1 array. Inside each array there are several number of data of array inside all 1851x1 array. How can I find the mean of each 1851 data. Thanks very much

Réponse acceptée

Image Analyst
Image Analyst le 12 Déc 2023
Did you try the obvious brute force for loop method:
theMeans = zeros(numel(X), 1);
for k = 1 : numel(X)
% Get the mean of the 1851 element double vector that is
% inside the kth cell of the X cell array.
theMeans(k) = mean(X{k});
end
  1 commentaire
Yat Chi
Yat Chi le 12 Déc 2023
Worked well, thanks very much for your help!

Connectez-vous pour commenter.

Plus de réponses (1)

Jalal Khan
Jalal Khan le 12 Déc 2023
cellfun(@mean,--) applies the mean function to each cell of the cell array and returns a numeric array containing the mean for each cell.

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by