Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Help speeding up/replacing loops
Date: Tue, 16 Jun 2009 18:43:01 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 18
Message-ID: <h18p3l$3u1$1@fred.mathworks.com>
References: <h18ge7$gta$1@fred.mathworks.com> <h18lud$rpl$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245177781 4033 172.30.248.35 (16 Jun 2009 18:43:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Jun 2009 18:43:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:548040


"James Wright" <jameswright1001@yahoo.co.uk> wrote in message <h18lud$rpl$1@fred.mathworks.com>...
> Is it even possible to replace loops like:
> 
> p(1) = B(1)*cos(C(f));
> q(1) = B(1)*sin(C(f));
> for n = 2:N
>       p(n) = p(n-1) + B(n)*cos(n*C(f));
>       q(n) = q(n-1) + B(n)*sin(n*C(f));
> end
> 
> 
> ??
> I'm starting to think that maybe it's not



P = cumsum(B(1:N).*cos((1:N)*C(f)));
Q = cumsum(B(1:N).*sin((1:N)*C(f)));