Conditional IF/ELSE Statement in Matlab
continue statement has a very different meaning. Within a loop, like a
continue instructs to skip the current round and continue with the next iteration in the loop. So if you remove
continue, you will see the behavior that you are expecting. Here is an example:
for k = 1 : 10 if k == 4 % skip the calculation in the case where k is 4 continue end area = k * k; disp(area); end
When the loop iterates at
k == 4, the block calculating the area of the corresponding square is skipped. This particular example is not very practical.
However, imagine you have a list of ten file names, and you want to process each file in this loop
for k = 1 : 10. You will have to try and open each file, but then if you find out the file does not exist, an appropriate way to handle it would be to print a little warning and then
continue to the next file.