MATLAB: Means of multiple vectors from different matrices

mean of multiple vecotrs

Hello I am trying to create a mean vector from multiple vectors (n=21) in 20 different matrices. Haven't used Matlab in a while so would greatly appreciate some help.Thanks!

Best Answer

You will need to explain better what you want to do. Give a small example, say 3 matrices, and show what you want to get at the end.
Your example kinda clarifies, but not enough. How is the data stored? Is each chemical a row or column? Say columns.
Say Na is stored in the first column of all matrices and you want the mean:
A = magic(3); % Day 1
B = hankel(1:3); % Day 2
C = toeplitz(1:3); % Day 3
mn = sum([A(:,1);B(:,1);C(:,1)] )/9;
Now depending on how the matrices are stored and named, there could be a better way. For example, using the above matrices:
save matrices A B C
X = load('matrices')
Bigmat = cell2mat(struct2cell(X));
mean(Bigmat) % Column means.