Quantcast
Channel: MATLAB Central Newsreader - tag:"mean"
Viewing all articles
Browse latest Browse all 26

Means of Multiple Vectors

$
0
0
I am running a loop (1000x), which contains 5 different vectors (A,B,C,D,E). I would like to find the mean across all vectors _per column, and output a single "averaged" vector for each (A,B,C,D, E) above. Vectors A, B, C, D, E all pull from other code generated randomly in other parts of the program, but for simplicity, I just used simple numbers below to represent the vectors. In the real program the vector lengths are 1x60.


Here is a sample of the program:


for j = 1:1000

A = [1,2,3,4,5]
B = [2,3,4,5,6]
C = [3,4,5,6,7]
D = [4,5,6,7,8]
E = [5,6,7,8,9]

j= j+1
end

mean=???

(To be clear - The answer I would be looking for from this example would be.....one vector mean = [3,4,5,6,7] - the average of each of the columns in all 5 of the vectors run 1000 times.

Viewing all articles
Browse latest Browse all 26