필터 지우기
필터 지우기

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

조회 수: 3 (최근 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