% This mfile shows an example of the continue statement clc clear all % for integers k=-10,-9,....,9,10, the function k^2-50 will take positive as % well as negative values. For example, for k=-9, k^2-50=31; for k=1, % k^2-50=-49; for k=8, k^2-50=14. % The loop below will calculate values of k^2-50 for all values of k. for k=-10:1:10 val=k^2-50; end % Let's suppose you are asked to print value of k^2-50 for % k=-10,-9,...,9,10 only for positive values of k^2-50. disp('Using for statement') for k=-10:1:10 if (k^2-50<0) continue end val=k^2-50; fprintf('\n k=%g val=%g',k,val) end disp(' ') disp(' ') disp('Using while statement') % Equivalent in while k=-10; while (k<=10) if (k^2-50>0) val=k^2-50; fprintf('\n k=%g val=%g',k,val) end k=k+1; end