tic toc delayed output inside for loop
I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration?I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration? I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration? timing, for loop MATLAB Answers — New Questions