[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Simple (and probably stupid) question about for loops
From: |
AlbFrigerio |
Subject: |
Simple (and probably stupid) question about for loops |
Date: |
Tue, 25 May 2010 06:29:42 -0700 (PDT) |
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.
Sorry to bother with this (probably) stupid question, but I cannot manage it
on my own.
Have a nice day,
Alberto
--
View this message in context:
http://octave.1599824.n4.nabble.com/Simple-and-probably-stupid-question-about-for-loops-tp2230002p2230002.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Simple (and probably stupid) question about for loops,
AlbFrigerio <=