continue - Pass control to next iteration of for or while loop
Syntax
continue
Description
continue passes control
to the next iteration of the for or while loop in which it appears, skipping
any remaining statements in the body of the loop. The same holds true
for continue statements in nested loops. That
is, execution continues at the beginning of the loop in which the continue statement
was encountered.
Examples
The example below shows a continue loop
that counts the lines of code in the file magic.m,
skipping all blank lines and comments. A continue statement
is used to advance to the next line in magic.m without
incrementing the count whenever a blank line or comment line is encountered.
fid = fopen('magic.m','r');
count = 0;
while ~feof(fid)
line = fgetl(fid);
if isempty(line) || strncmp(line,'%',1) || ~ischar(line)
continue
end
count = count + 1;
end
fprintf('%d lines\n',count);
fclose(fid);See Also
for, while, end, break, return
 | conj | | contour |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit