Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: avoid loops
Date: Mon, 23 Mar 2009 14:50:18 +0000 (UTC)
Organization: Univ of Newcastle upon Tyne
Lines: 34
Message-ID: <gq87ja$9ug$1@fred.mathworks.com>
References: <gq84j5$oj7$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1237819818 10192 172.30.248.37 (23 Mar 2009 14:50:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 23 Mar 2009 14:50:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1511480
Xref: news.mathworks.com comp.soft-sys.matlab:526957

"Jose " <jose.l.vega@gmail.com> wrote in message <gq84j5$oj7$1@fred.mathworks.com>...
> Somebody can help me to avoid the first loop in j?
> Thanks in advance.
> Jose.
> 
> Code:
> 
> nrv=10 % random variable
> 
> nrp=100 % number of 2D-points x(nrp,:)
> 
> y=zeros(1,nrp);
> z=zeros(1,nrv);
> 
> for j=1:nrv   % I want to avoid this loop.
> a=[rand(1,1) rand(1,1)]
> 
> for i=1:nrp
> y(i)=x(i,:)-a
> end
> 
> z(j)=sum(y)



> 
> end
> 
> zt=sum(z)/nrv


Sorry, I made a msprint:

sorry, y(i)=x(i,:)*a'