Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Avoiding loops in a symmetric matrix.
Date: Fri, 5 Dec 2008 15:33:02 +0000 (UTC)
Organization: Univ of Newcastle upon Tyne
Lines: 42
Message-ID: <ghbhje$e2j$1@fred.mathworks.com>
References: <ghbdre$ahh$1@fred.mathworks.com> <ghbgle$s08$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1228491182 14419 172.30.248.38 (5 Dec 2008 15:33:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 5 Dec 2008 15:33:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1511480
Xref: news.mathworks.com comp.soft-sys.matlab:505199


Hi Matt, could you explain me how i can do it with circshift?
I need to make the differences of 200 vectors and 100 components,
it take 5 minutes, and -i have to get it in secs, :)
I wrote a short example, to explain my problem.
Cheers,
Jose.


"Matt" <mjacobson.removethis@xorantech.com> wrote in message <ghbgle$s08$1@fred.mathworks.com>...
> "Jose " <jose.l.vega@gmail.com> wrote in message <ghbdre$ahh$1@fred.mathworks.com>...
> > Hi,
> > I have 10 vectors with 10 components, u(1:10,1:10).
> > 
> > And I am interested to calculated the differences between vectors  avoiding the diagonal components, because I am not interested in a high correlation between components.
> > 
> > This is my code, it works, but is not efficient, I would like to avoid the loops, but
> > I do not know how I can do it:
> > 
> > for i=1:10
> >    
> >     for j=1:10
> >         if j~=i 
> >         dx=u(i,:)-u(j,:);
> >         
> >    if i==1 & j==2
> >    delta=dx;
> >    else 
> >        delta=[delta;dx];
> >    end
> >         end
> >         end
> > 
> > Please, anyone can help me to try to built the delta correlation matrix of another form more efficient.
> > Thanks in advance,
> > Jose.
> 
> 
> You can eliminate one loop using circshift(). I don't see a way you can avoid both.
> 
> But why do you care? It's such a small amount of data.
>