23.12.2012 Views

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

continue<br />

2continue<br />

Purpose Pass control to the next iteration of for or while loop<br />

Syntax continue<br />

Description continue passes control to the next iteration of the for or while loop in which<br />

it appears, skipping any remaining statements in the body of the loop.<br />

2-310<br />

In nested loops, continue passes control to the next iteration of the for or<br />

while loop enclosing it.<br />

Examples The example below shows a continue loop that counts the lines of code in the<br />

file, magic.m, skipping all blank lines and comments. A continue statement is<br />

used to advance to the next line in magic.m without incrementing the count<br />

whenever a blank line or comment line is encountered.<br />

fid = fopen('magic.m','r');<br />

count = 0;<br />

while ~feof(fid)<br />

line = fgetl(fid);<br />

if isempty(line) | strncmp(line,'%',1)<br />

continue<br />

end<br />

count = count + 1;<br />

end<br />

disp(sprintf('%d lines',count));<br />

See Also for, while, end, break, return

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!