condition in a loop

1 Ansicht (letzte 30 Tage)
Busy Bee
Busy Bee am 29 Jan. 2018
Kommentiert: Busy Bee am 29 Jan. 2018
I have the loop as given below. But I need to restrict the value of b till 30, i.e. the value of b cannot exceed 30. 'a' value does not have a limit. I am not sure how to proceed.
a=0;
b=0;
g=a+b;
while g<100
a=a+1
b=b+1
g=a+b
end

Akzeptierte Antwort

Birdman
Birdman am 29 Jan. 2018
Bearbeitet: Birdman am 29 Jan. 2018
a=0;
b=0;
g=a+b;
while g<100
if b<30
b=b+1
else
end
a=a+1
g=a+b
end

Weitere Antworten (0)

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!

Translated by