total mean of big amount of DATA in cell arrey

4 ビュー (過去 30 日間)
hadi mostafavi amjad
hadi mostafavi amjad 2020 年 11 月 7 日
回答済み: Ameer Hamza 2020 年 11 月 7 日
Hi MATLABians
I have a cell with size of 10 * 25, and each array of this cell arrey include of different size of matrices like 31 * 38 (no matter). So i wanna take mean of this cell arrey, also wanna take total mean of each arrey of this cell and put it into an vector and then mean of the other arreys of this cell into that vec. And finally take the total mean of this vector. The result should be the total mean of the primary cell.
thank you for HELPing!

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 11 月 7 日
following will calculate the mean of each cell seperately
C; % 10x25 cell array
C_means = cellfun(@(x) mean(x, 'all'), C)
However, note that since if you simply take the mean of C_means. It will not represent the mean of all elements since each cell has a matrix of different sizes. So you need a weighted average. For example
C; % 10x25 cell array
C_means = cellfun(@(x) mean(x, 'all'), C);
C_elements = cellfun(@numel, C);
C_mean_all = mean(C_means.*C_elements, 'all')/sum(C_elements, 'all')

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by