Jessica wrote:
> dpb <none@non.net> wrote in message
> <hr9c9n$1qn$1@news.eternalseptember.org>...
>> Jessica wrote:
>> > I am running the loop:
>> > > for i=1:10
>> > b=i+1;
>> > if Question=='1'
>> > b=7;
>> > i=8; %I want to change this!
>> > end;
>> > end;
>> > > > I want this loop to run such that if Question==1 and I'm on the
>> 2nd > iteration of the loop, the next iteration of the loop with be
>> the 8th > time around (that is, i=8). In this manner, the loop would
>> not run > through i=37.
>>
>> doc continue % you'll need another test as well as 'Question'
>>
>> or restructure w/ uncounted loop construct
>>
>> 
>
> I'm relatively new to programming. Can you provide a little more detail
> on going about this? Thanks!
Nothing ventured, noting gained... :( Why not make a stab at it???
for i=1:10
b=i+1;
if Question=='1'
b=7; % you really want this here???
if i>1 && i<8, continue,end
end;
end;
Depending on what the rest of the logic looks like, a while construct w/
explicitly counting the loop might be useful to jump the index...
>> q='1';
>> i=1;
>> i=1;while i<11, disp(i), if i==2 & q=='1',i=8,end,i=i+1;end
1
2
i =
8
9
10
>>
BTW, "i" (and "j" as well) are not good choices for iteration variables
in Matlab even though they're ubiquitous elsewhere. In ML, they are
defined as the imaginary i and j
After the above keyboard exercise...
>> which i
i is a variable.
>> clear i
>> which i
i is a builtin function.
>>

