From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Summing consecutively signed integers
Date: Mon, 26 Nov 2012 22:42:19 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 6
Message-ID: <k90r8b$ddn$>
References: <k90dmu$oq9$> <k90kti$l3c$> <k90lid$ncb$> <k90njp$uir$> <k90p6c$64m$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1353969739 13751 (26 Nov 2012 22:42:19 GMT)
NNTP-Posting-Date: Mon, 26 Nov 2012 22:42:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:783542

"K" wrote in message <k90p6c$64m$>...
> Darn, I was afraid of that.
- - - - - - - - -
  I agree with dpb.  I see a vectorized method that would give you the answer you are asking for, but I don't want to give it to you, because it is very awkward and inferior to an obvious and simple for-loop method.  You should realize that for-loop and while-loop code constructs provide a very powerful means of algorithm computation and there is nothing disgraceful about using them.  Buried within the underlying C compiler code of nearly all Mathworks "elegant" functions are the equivalent of many for-loops, and I don't think their programmers are in the least bit reluctant about using them.  The thing you should always strive for is an efficient algorithm in terms of the operations a computer must perform, never mind whether it uses for-loops or not.

Roger Stafford