[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple (and probably stupid) question about for loops
From: |
Jaroslav Hajek |
Subject: |
Re: Simple (and probably stupid) question about for loops |
Date: |
Tue, 25 May 2010 15:57:35 +0200 |
On Tue, May 25, 2010 at 3:29 PM, AlbFrigerio
<address@hidden> wrote:
>
> Hi everyone, I believe I'm really rusty in using Octave cause I'm trying to
> do a very simple thing (in my mind) but I cannot succed in it. I tried to
> read the guide and some posts on for loops, but I haven't managed anything.
>
> Here it is my question : is it possible to update the value of the for index
> inside the loop?
>
> For example, I wrote the following code :
>
> for k=1:10
> k
> if k==2
> k=5;
> endif
> endfor
>
> I'd like the output to be : 1 2 6 7 8 9 10 , but it always gives me 1 2 3 4
> ... 10 . It sounds like the k variable in the loop to be completely
> different from the one used in the loop.
>
> Is there a way to solve this problem? I could obviously use a while or do
> loop, I just wanna know if there is a way with for ones.
>
no.
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz