How I can create a while cycle that ends after a sepecific time

2 visualizaciones (últimos 30 días)
my aim is make a wile cilce that run for a specific time T. For exemple
T=60 %sec
while(t==60)
t=time.
for i=0:10
d=sum(i+)
.
.
.
.
.
.
end
end
%where t start from zero and go on whit the time
%t is 1 after 1 second

Respuesta aceptada

Sylvain
Sylvain el 3 de En. de 2023
tic
while(toc<60)
  % code
end

Más respuestas (1)

Eric Sofen
Eric Sofen el 4 de En. de 2023
I think timer is likely to give you better precision for this sort of thing than tic/toc (tic/toc is better for timing performance of a function or script). The reference page for timer illustrates exactly this while-loop scenario.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by