Setting timer to repeat a dos command

10 visualizaciones (últimos 30 días)
Gabriel Silva
Gabriel Silva el 5 de Feb. de 2020
Comentada: Geoff Hayes el 7 de Feb. de 2020
hi there!
I 've got a little problem with scripts like this one:
t = timer('TimerFcn', 'stat=false','StartDelay',10);
start(t)
stat=true;
while(stat==true)
dos('dir')
datetime
pause(10)
end
stop(t)
delete(t)
It works one time only or keep repeating ad infinitum. I'm using R2016a.
  3 comentarios
Gabriel Silva
Gabriel Silva el 5 de Feb. de 2020
Well, Geoff, it's the same timer example, but using some dos commands. I do not remove the pause. I hope this particular script to repeat 'dir' 10 times, but it gives me only one. I put a pause of 30 seconds, but then I reduce it to 10. Not working, anyway.
Geoff Hayes
Geoff Hayes el 7 de Feb. de 2020
Gabriel - why not try a pause of 0.5? or even 1.0 seconds? I think that because you are pausing for ten seconds and because your timer expires after ten seconds (due to the StartDelay property being 10), you will only ever see dir be called once...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by