I have a loop like this:
b = 1;
for c = 1 : 10;
if b == 1
c = 1 + 3
end
end
What do I need to do to make to change c?
Because as I read through the help, MATLAB resets the loop counter c after it reaches end.
Is there any way to change the value of the loop counter from within a for loop?
you could use a while loop instead of a for loop.
something like (I'm guessing you want to add 3 to c otherwise c = 4 could replace that line below)
b = 1;
c = 1;
while(c < 10)
if b == 1
c = c + 3
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With