|
"Milind" <melindmm@yahoo.com> wrote in message
news:h62eh5$f84$1@fred.mathworks.com...
> Hello, I've a timer object which calls the specified timer function, now
> my question is how can I return a variable from the callback function.
> Below is the code:
>
> a=timer;
> set(a,'ExecutionMode','fixedRate');
> set(a,'Period',0.001);
> a.timerFcn ={'Get3Chan',s,m}
>
> start(a);
>
> So, here it calls the function 'Get3Chan'. Now,I want to return a variable
> from 'Get3Chan' to the main code. How to do this?
You can't. Suppose you set a timer running in a function (storing the timer
object in a figure's UserData or returning it from the function) and then
the function exits before the timerFcn executed. To what workspace would
you expect the timerFcn to return the variable?
What you could do is have the timerFcn store the "return value" in the
timer's UserData property, in a figure's UserData property, or in the
application data using SETAPPDATA and have the function that wants to use
that "return value" retrieve it from where it was stored.
--
Steve Lord
slord@mathworks.com
|