How to apply stop time condition with multiple time intervals?
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!