mercredi 6 juillet 2016

display variable value each n iterations with condition outside the loop

When I have to display the variable value every n iterations of a for loop I always do something along these lines:

for ii=1:1000
  if mod(ii,100)==0 
     display(num2str(ii))
  end
end

I was wondering if there is a way to move the if condition outside the loop in order to speed up the code. Or also if there is something different I could do.

Aucun commentaire:

Enregistrer un commentaire