|
In article <fc6rrc$a2$1@fred.mathworks.com>, "Anish Goorah"
<anish.goorah@mathworks.com> wrote:
> ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)
> wrote in message <ellieandrogerxyzzy-
> 1109071226280001@dialup-
> 4.232.60.182.dial1.losangeles1.level3.net>...
> > In article <fc6ons$6p$1@fred.mathworks.com>, "Anish
> Goorah"
> > <anish.goorah@mathworks.com> wrote:
> >
> > > I want to eliminate the for loop for something like
> this:
> > >
> > > T = 100;
> > > K = 5;
> > > X = rand(T,K);
> > >
> > > D = zeros(K,K);
> > > for i=1:K
> > > for j=1:K
> > > D(i,j) = mean((X(:,i) - mean(X(:,i))).*(X(:,j) -
> ...
> > > mean(X(:,j))));
> > > end
> > > end
> > >
> > > Any ideas? Thanks
> > --------------------------
> > Try this:
> >
> > D = X-repmat(mean(X),T,1);
> > D = D.'*D/T;
> >
> > Roger Stafford
>
> Beauty. Thanks
-------------
I should also mention that you can accomplish the same thing with:
D = cov(X,1);
Roger Stafford
|