
Re: statistics across multiple dimensions
Posted:
Apr 20, 2011 7:01 PM


Thanks. This works.
regs bala
Doug Schwarz <see@sig.for.address.edu> wrote in message <seeDE124D.23454906042011@news.frontiernet.net>... > In article > <8c7d24002b784af7b35b6ad8d96f2064@e9g2000vbk.googlegroups.com>, > TideMan <mulgor@gmail.com> wrote: > > > On Apr 7, 12:10 pm, "Balachander Narasimhan" > > <balxxxxxch...@whatever.com> wrote: > > > Hi, > > > > > > I have a 3D array. If I need the mean of all elements in two dimensions of > > > this array, I can do something like > > > > > > mean(mean(a,1),2) to average over the first two dimensions of 3D array a > > > lets say of size 5x5x5 > > > > > > But I cannot do the same for variance. One of the options seems to be > > > > > > for k =1:5 > > > b = a(:,:,k); > > > v(k) = var(reshape(b,25,1)) > > > end > > > > > > Is there a way to avoid this loop? > > > > You can do the same with var, only the dimension is the third > > argument, not the second: > > var(var(a,0,1),0,2) > > No, the mean of the mean is the mean of the whole matrix, but the > variance of the variance is not the variance of the whole matrix. > > To the OP: > > a = rand(l,m,n); > v = var(reshape(a,[],n)); > >  > Doug Schwarz > dmschwarz&ieee,org > Make obvious changes to get real email address.

