I am currently working on parallel timing function, as a timing threshold, that can be applied to the main function. A maximum running time is needed. Once the threshold is reached, the main function would break and enter the next loop.
My original idea was to call timer
from another independent function so that a parallel function would be possible. But it fails to do so.
function timeStop()
time = cputime;
time = cputime-time;
a = timer;
set (a, 'executionMode', 'fixedRate')
set (a,'timerfcn','disp(time)')
start(a)
timeStop = time;
end
Then calling this timeStop
,
function fucx()
for i = 1:3
for j = 1:3
for k = 1:3
try
%MainFuc()
timeStop
if (timeStop>60) % in seconds
disp('RunOutOfTime: Program terminated');
stop(a)
break;
end;
catch
%%Err()
end
end
end
end
end
It is a huge collection of model setting, study, and solutions in MainFunc()
, without loops. I was thinking about directly putting the tic/toc
function into the MainFuc()
. But I am not sure whether MATLAB internally would work the way that I want it to. Because I do not know which step or code line the infinite time was trapped in MainFunc()
. I cannot simply put the tic/toc
function with it if it is not determined in parallel.
I have considered using tic/toc
, but I was told that internally MATLAB would only know the running time after the full execution of MainFuc()
. I am not sure if this is true, but found posts with a similar meaning in different locations.