[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reducing for loop
From: |
Dr.-Ing. Dieter Jurzitza |
Subject: |
Re: Reducing for loop |
Date: |
Thu, 26 Mar 2015 21:01:43 +0100 |
User-agent: |
KMail/1.13.6 (Linux/3.11.10-25-desktop; KDE/4.11.5; x86_64; ; ) |
Dear listmembers,
many thanks for the helpful replies! Indeed I did not know about cumsum, what
does exactly what I wanted to achieve, big thank you to Przemek, Markus and
Oliver!
I saw that this:
***********
for i=2:n
B=A(i)+B(i-1);
endfor
***********
was wrong anyway, I had had intended to write only B=A(2:n)+B(1:n-1) but this
didn't work either, cumsum did the job - nicely.
Thank you very much,
take care
Dieter Jurzitza
--
-----------------------------------------------------------
|
\
/\_/\ |
| ~x~ |/-----\ /
\ /- \_/
^^__ _ / _ ____ /
<°°__ \- \_/ | |/ | |
|| || _| _| _| _|
if you really want to see the pictures above - use some font
with constant spacing like courier! :-)
-----------------------------------------------------------