On 7/10/2015 2:06 PM, jefkei92 wrote:
> 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.
>
mean([A;B;C;D;E])
ans =
3 4 5 6 7
from help:
"S = mean(X) is the mean value of the elements in X if X is a vector.
For matrices, S is a row vector containing the mean value of each
column. "
> 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.
>
mean([A;B;C;D;E])
ans =
3 4 5 6 7
from help:
"S = mean(X) is the mean value of the elements in X if X is a vector.
For matrices, S is a row vector containing the mean value of each
column. "