Tic Toc callback problem
5 次查看(过去 30 天)
显示 更早的评论
I have a callback function in my code. I have tried to time from outside the callback function to a point within the callback function using the tic toc function. But it doesn't bring in the tic time into the callback function. How can i do this . I have heard about a function called global can bring variables into a callback but i have not managed to get it done with tic toc? Thanks :)
0 个评论
回答(2 个)
Image Analyst
2013-4-18
Yes. Look at the documentation for tic. Anywhere in your m-file:
global tic;
tic1 = tic;
Then in your callback code
global tic1;
elapsedTime = toc(tic1);
You can have multiple "Tic"s running simultaneously.
per isakson
2013-4-18
Your question is vague. Hint:
Somewhere
...
global et
...
'Callback', @the_callback_function
...
where
function the_callback_function( ... )
global et
tic
... some code
et = toc;
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!