How to apply stop time condition with multiple time intervals?
Show older comments
n=100;
tic
Time = 0;
for i = 1:n
if Time >= 35
fprintf('You run out of time')
break
end
A = rand(12000,4400);
Time1 = toc;
B = rand(12000,4400);
tic
C = A.*B;
Time2 = toc;
tic
D = A./B;
Time3 = toc;
E = A.*A;
tic
E = B.*B;
Time4 = toc;
Time = Time1 + Time2 + Time3 + Time4;
end
I want to stop the code when Time = 35 sec, I have tried the above but my code is not terminating the code at specified time?
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!