how to write a loop with variable limits
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
farzad
am 18 Mär. 2015
Kommentiert: per isakson
am 11 Apr. 2015
Hi All
I want to write a for loop like :
for j=a:b
bla bla
end
but I need another loop above this , that check a condition ,and if that condition like(c > 0) is not satisfied , add a certain amount to a and b in a way that , if the first time a=1 and b = 100 , the next one will be : a= 101 and b= 200 and then next one be : a= 201 and b= 300 , and when the condition is satisfied , MATLAB exits the loop add a quantity
Akzeptierte Antwort
per isakson
am 18 Mär. 2015
Bearbeitet: per isakson
am 18 Mär. 2015
Hint:
while condition == false
if not(c>0)
a = a + something;
b = b + something;
end
for jj = a : b
bla bla
end
end
3 Kommentare
per isakson
am 11 Apr. 2015
Depends on what you want to achieve. I don't fully understand your question. My hint is kind of pseudo code. Another try:
while not(c>0)
a = a + something;
b = b + something;
for jj = a : b
bla bla
end
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!