means of multiple vectors from different matrices

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!

 Réponse acceptée

Matt Fig
Matt Fig le 4 Mar 2011
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.

2 commentaires

Nancy
Nancy le 4 Mar 2011
thanks Matt...here is an example....I have time series (a matrix) of several measurements (say a matrix with chemical concentration of sodium, aluminum and chloride) from day 1, day 2 and day 3. I want to get the mean time series of one chemical element (say sodium) by averaging the time series from the three different days. Does that example help?
Nancy
Nancy le 4 Mar 2011
thanks Matt--very helpful--much appreciated!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Chemistry dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by