Borrar filtros
Borrar filtros

Running Script using Timer

6 visualizaciones (últimos 30 días)
KKR
KKR el 5 de Dic. de 2013
Editada: per isakson el 30 de Sept. de 2016
I am trying to use Timer function to run a script at pre-specified interval (30 seconds). However, most of the examples, including MATLAB help, is directed towards using callback functions. However, when I tried something similar to use the script to run using timer, I get an error message.
Specifically, I am using Bloomberg's data function to get real time data and would like to simply revoke that Bloomberg function every 30 seconds.
Any help would be sincerely appreciated. Please feel free to ask question, if I am not being clear.
Thank you,

Respuestas (2)

per isakson
per isakson el 5 de Dic. de 2013
Editada: per isakson el 6 de Dic. de 2013
The trick is to use an anonymous function. Try
>> my_timer_test
2013-12-05 22:09:31
2013-12-05 22:09:43
2013-12-05 22:09:55
2013-12-05 22:10:07
where
%%my_timer_test
tmr = timer ...
( 'Name' , 'my_timer' ...
, 'TimerFcn' , @(x,y) my_script ...
, 'BusyMode' , 'drop' ...
, 'ExecutionMode' , 'fixedDelay' ...
, 'Period' , 12 ...
, 'StartDelay' , 1 ...
);
start( tmr )
and
%%my_script
disp( datestr( now, 31 ) )
are two script files
  8 comentarios
KKR
KKR el 19 de Dic. de 2013
Somehow it gives me an error - every time it goes to second iteration - first time invoke works perfectly fine.
per isakson
per isakson el 19 de Dic. de 2013
What does "it" refer to? Isn't it a case for ordinary debugging? http://undocumentedmatlab.com/ may have something useful to say on debugging Java code.

Iniciar sesión para comentar.


KKR
KKR el 7 de Dic. de 2013
That worked.
Sorry about inconvenient code description.
Thank you very much for the help.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by