Execute a command after a delay
    8 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Leo Simon
      
 el 1 de Jun. de 2016
  
    
    
    
    
    Comentada: Antonio Del Negro
 el 10 de Oct. de 2018
            Based on this thread I'm not optimistic, but thought I'd give it a try. I'd really like to be able to execute a command after a delay, e.g., run a script that says
pause(10); disp('Hullo')
but have the program continue during the pause time, so that code lines can be executed before the disp command. In linux, one could do this by "backgrounding" the command string. Maybe there's some fancy undocumented way of doing this in matlab? If not it would be a great addition.
0 comentarios
Respuesta aceptada
  Sean de Wolski
      
      
 el 1 de Jun. de 2016
        Use a timer with a start delay.
T = timer('StartDelay',10,'TimerFcn',@(src,evt)disp('Hello World'));
start(T)
surf(peaks) % something running while timer waiting
And for more info:
doc timer
2 comentarios
  Antonio Del Negro
 el 10 de Oct. de 2018
				what if I'm running the same command inside a MATLAB function block of Simulink? I'm saying this because I tried doing so and the following appears:
"The Timer class does not support code generation"
Any alternative for the case of a matlab function block from simulink? I've been looking all day. Thanks!
Más respuestas (0)
Ver también
Categorías
				Más información sobre Startup and Shutdown 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!


