I have written a function in MATLAB. Within that function I use:
t = cputime;
...
time = cputime-t;
Where I have some operations at the dots. Whenever I don't call the function and instead run the code in the function manually, I always have time = 0.15 etc.
However, in another script, I am calling this same function. In the first call, it is again giving me time = 0.15. BUT, if I clear the workspace and call the function again, I have time = 0. Just 0, no decimals. I don't know why, because the function is working and giving me what I want. If I instead run the code in the function many times, I never have time = 0.
What is the possible issue? Why calling a function from the script more than once makes it 0 seconds even if the workspace is cleared?