www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SkipToNextLoopIterationExample.m
%% Skip to Next Loop Iteration % Count the number of lines of code in the file |magic.m|. Skip blank % lines and comments using a |continue| statement. |continue| skips the % remaining instructions in the |while| loop and begins the next iteration. % Copyright 2015 The MathWorks, Inc. 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 count fclose(fid);