meanMatrix = (matrix1 + matrix2 + matrix3 + .... etc...... + matrix 30 + matrix31)/31; Answer from Image Analyst on mathworks.com
Top answer 1 of 4
4
meanMatrix = (matrix1 + matrix2 + matrix3 + .... etc...... + matrix 30 + matrix31)/31;
2 of 4
6
M={A,B,C,D,E};
B=cat(3,M{:})
out=mean(B,3)
Top answer 1 of 2
1
Yes, concatenate the matrices into a 3-D array and use mean(x,3)
x = randn(4,4,10);
mean(x,3)
and
std(x,[],3)
To concatenate, you can use cat()
x = randn(4,4);
y = randn(4,4);
z = cat(3,x,y);
mean(z,3)
std(z,[],3)
2 of 2
1
Stack your 40 matrices into one three-dimensional matrix, then take the mean along the 3rd dimension
meanMatrix = mean(stackedMatrix,3); %doc mean for more info.
To stack your matrices look at these two FAQs:
*
*
How can get the average between two array ?
How can get the average between two array ?. Learn more about MATLAB More on mathworks.com
Average of multiple cell arrays
Average of multiple cell arrays. Learn more about cell arrays, complex double More on mathworks.com
Average difference of multiple arrays
Average difference of multiple arrays. Learn more about array MATLAB More on mathworks.com
mean over over multiple dimensions and multiple arrays
So i am seeking to to average each x,y element over the 8 arrays at each depth, resulting in one 814*1294*40 array. ... Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/572608-mean-over-over-multiple-dimensions-and-multiple-arrays#answer_472747 More on mathworks.com
MathWorks
mathworks.com › matlabcentral › answers › 541571-average-of-multiple-cell-arrays
Average of multiple cell arrays - MATLAB Answers - MATLAB Central
June 3, 2020 - Hi all. I've figured out how to get the average of multiple cell arrays so that the end product is a 1x22051 complex double. However, is there a code that could simplify this? I have over 50 cell a...
MathWorks
mathworks.com › matlabcentral › answers › 424381-average-difference-of-multiple-arrays
Average difference of multiple arrays - MATLAB Answers - MATLAB Central
October 16, 2018 - I have 8,000+ arrays that I'd like to compare against each other. I'd like to determine the average number of similar elements each array to all other arrays. I've managed to calculate the val...
Top answer 1 of 2
3
Hi, if you have Statistics Toolbox, you can use |nanmean| as follows:
matrixA = [2 3 5 ; 3 NaN 1 ; 2 4 3];
matrixB = [3 4 NaN ; 1 2 5 ; NaN 3 5];
matrixC = [NaN 2 3 ; 2 5 3 ; 1 2 1];
allData = cat(3,matrixA,matrixB,matrixC);
nanmean(allData,3);
2 of 2
2
*Edit*
matrixA = [2 3 5 ; 3 NaN 1 ; 2 4 3]
matrixB = [3 4 NaN ; 1 2 5 ; NaN 3 5]
matrixC = [NaN 2 3 ; 2 5 3 ; 1 2 1]
A={matrixA matrixB matrixC}
B=cat(3,A{:})
idx=find(isnan(B))
C=ones(size(B));
C(idx)=0;
B(idx)=0;
out=sum(B,3)./sum(C,3)
MathWorks
mathworks.com › matlabcentral › answers › 731953-averaging-multiple-matrices-with-the-cell-array
Averaging multiple matrices with the cell array - MATLAB Answers - MATLAB Central
January 31, 2021 - Hi Guys, I have a cell array (C) with (1*22), inside this cell i have 22 matrices with (30*30*20). I want to have the average of all these matrices, so the final output must be in the same dime...
Reddit
reddit.com › r/matlab › make an average array - different size arrays
r/matlab on Reddit: Make an Average Array - Different Size Arrays
November 29, 2023 -
I am trying to map the average behavior of our series of tests. We ran the same test 10 times and had 10 arrays of data. The problem is the specimen failed at different points each test, so the arrays are all different sizes (and quite large, 14820 rows in the smallest)
How can I create an array of the average values? Plot in the comments for reference.
I think I would need to make all the arrays the same size, filling the added space with zeros, but I don't know an efficient way to do that at this scale.
Top answer 1 of 3
2
As a general strategy, you could generate a large default array using zeros() based on the largest matrix. Then assign all the data into the large nan (or zeros) array and then manually calculate the average. Simple Example: A_tmp = rand([3,4]); B_tmp = rand([7,4]); C_tmp = rand([5,4]); defArry = zeros([max([size(A_tmp,1) size(B_tmp,1) size(C_tmp,1)]),4]); A = defArry; A(1:size(A_tmp,1),1:4) = A_tmp; B = defArry; B(1:size(B_tmp,1),1:4) = B_tmp; C = defArry; C(1:size(C_tmp,1),1:4) = C_tmp; D = (A + B + C) / 3
2 of 3
2
I would pad with NaNs, not zeros, that way you don't make unjustifiable assumptions about the behavior of your system in regimes outside of observation. To efficiently pad, find the size of the largest array and set the value of the elements numel+1:largestSize equal to NaN for all other arrays, such as: padSize = numel(largestArray); myArray(numel(myArray)+1:padSize) = NaN; Then to calculate the average, put all arrays into their own row or column of a single matrix and compute the mean across the rows or columns, omitting NaNs. Your sample size will decrease as each recording drops off as x increases, so the variance will also increase. This is not a bug but a characteristic of your data - the larger x gets the less predictive power you have because you don't have as much data there.
MathWorks
mathworks.com › matlab › data import and analysis › descriptive statistics and insights
mean - Average or mean value of array - MATLAB
This MATLAB function returns the mean of the elements of A along the first array dimension whose size does not equal 1.
MathWorks
mathworks.com › matlabcentral › answers › 486696-finding-mean-for-multiple-matrices
Finding mean for multiple matrices - MATLAB Answers - MATLAB Central
October 22, 2019 - Finding mean for multiple matrices. Learn more about mean, one dimentional matrix, mean of matrices
MathWorks
mathworks.com › matlabcentral › answers › 300227-how-to-calculate-a-average-of-five-arrays
how to calculate a average of five arrays? - MATLAB Answers - MATLAB Central
August 19, 2016 - I have a small problem in a exercise. So i have to make dynamic vectors with 3 dimentions and calculate the average of the sum of all vector's, how can I do this? example: if true V = []...
MathWorks
mathworks.com › matlabcentral › answers › 875313-finding-the-mean-of-data-with-different-array-sizes
Finding the mean of data with different array sizes - MATLAB Answers - MATLAB Central
July 9, 2021 - https://www.mathworks.com/matlabcentral/answers/875313-finding-the-mean-of-data-with-different-array-sizes ... I have multiple arrays, each with a percentage column and a data column. The lengths of the arrays are all different, although the values all go from 0 to 100% in the first column. I would like to average the data in order to investigate any trends, but I am not sure how to average the data while the matrix lengths are all different.
MathWorks
mathworks.com › matlabcentral › answers › 75910-mean-of-2-arrays
Mean of 2 arrays - MATLAB Answers - MATLAB Central
May 15, 2013 - Hi, I have 2 arrays in a cell: imag = [1130x2120 double] [1130x2120 double] How can i calculate the mean of both arrays together not of each one?
MathWorks
mathworks.com › matlabcentral › answers › 46072-calculation-of-a-mean-matrix
calculation of a mean matrix - MATLAB Answers - MATLAB Central
August 15, 2012 - Hi I have two matrices a = [1 2 3; 2 3 4] and b = [2 3 4; 3 4 5]; I want a mean output matrix "c," whose output should be c= [1.5 2.5 3.5; 2.5 3.5 4.5]. so basical...