Sunday, 31 July 2016

MATLAB Programming 40 - continue statement in while loop (Example)

Example


Create a script file and type the following code:


a = 10;

while a < 20

     if a == 15     

     a = a + 1;

     continue;

     end

fprintf('value of a: %d\n', a);

a = a + 1;

end


When you run the file, it displays the following result:


value of a: 10

value of a: 11

value of a: 12

value of a: 13

value of a: 14

value of a: 16

value of a: 17

value of a: 18

value of a: 19

No comments:

Post a Comment