I have a function "test". Inside this test function, I have a for loop that goes from 1 to N. Since I want to know the average time for each iteration, I put tic /toc, and a variable called "Time_for" will give me the average time, as you can see in the code below
Now, I want to compute the time execution of the function. For this purpose, in the main of the program, I use the timeit function, as you can see below
My problem is that, when I run timeit, the variable "Time_for", that should just be displayed only once, it is actually displayed 10 times. And for each of these 10 times, the value slightly changes.
Why the toc function, inside a timeit, is computed multiple times?