Hi,
I understand you are observing different tic toc values while you are trying to measure the performance of your code. The execution time can be influenced by the current load on your computer's CPU and memory.
As per MathWorks documentation for measuring performance, it states: "Unless you are trying to measure first-time cost, run your code multiple times. Use the timeit function".
In order to perform a robust measurement, try using "timeit" function. It calls the specified function multiple times and returns the median of the measurements.
For more information on "timeit" function and performance measurement, please refer to the following MathWorks documentation:
- https://www.mathworks.com/help/matlab/ref/timeit.html
- https://www.mathworks.com/help/matlab/matlab_prog/measure-performance-of-your-program.html
I hope this helps!