Getting mean row vector from a cell array of row vectors of the same size

1 次查看(过去 30 天)
Hi there,
I have a cell array of 1x60, each containing a double/row vector of 1x256 - each of these a histogram of an image of values from 0 to 255.
I need to find the mean row vector/histogram across all 60 of these images i.e. the average of cells 1-256 across all 60. I understand the logic but don't know how to code it.
Any help would be very much appreciated. Thank you.

采纳的回答

Jonas
Jonas 2021-5-26
编辑:Jonas 2021-5-26
so if i understood you correctly each cell contains histogram values with 256 bins each and you want to know mean count for each bin: in this case use cell2mat which converts your 1x60 cell to a 256x60 matrix. the use mean() which operates columnwise. then you get medium count for each bin

更多回答(1 个)

Allen
Allen 2021-5-26
It is not entire clear to me what you are trying to average. However, if I am understanding correctly, the following example attempts to duplicate your 1x60 cell-array with 1x256 numerical arrays, where each numerical array contains a randomly assigned value from 0 to 255 for each element. I then determine the average of all values in each 1x256 numerical array and since there are 60 elements in the cell-array, the end result is a 1x60 numerical array. If this not what you are looking for please provide more details and include your an example of your initial data and a few snippets of code that you have already attempted.
% Attempts to duplicate your datasets as elements in a cell-array (each cell-array element is a 1x256 numerical array)
C = arrayfun(@(x) randi([0,255],[1,256]),1:60,'un',0);
% Calculates the overall average for each element in the cell-array
avg = cellfun(@mean,C);

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by