- https://www.mathworks.com/matlabcentral/answers/332551-matlab-timer-is-not-executed-asynchronously
- https://www.mathworks.com/matlabcentral/answers/414967-how-to-execute-timer-functions-in-matlab-gui-in-parallel
Running two independant background tasks on two cores
2 次查看(过去 30 天)
显示 更早的评论
I coded a program that opens a GUI and runs a script in the background using a timer. Very basically, the background script checks (as often as possible) for changes from a Tucker Davis Technologies (TDT) interface and runs indefinitely until it is stopped from the GUI. The GUI is used to edit variables on the fly, and to display some input from the TDT interface.
I now need to get data from an eyetracker (on the fly) at the same time. The easiest way would have been to run a second timer in parallel with the first one. But of course, both timers run on the same core and prevent eachother to run properly.
Is there a solution to achieve what I need to do?
I have the parallel computing toolbox installed.
Thanks.
0 个评论
回答(1 个)
Deep
2024-9-12
Hi Mitraz,
To run two independent background tasks on separate cores in MATLAB, you can utilize the Parallel Computing Toolbox to execute timer objects in separate tasks. This approach allows each timer to be processed by a different MATLAB worker, effectively overcoming the limitation of both timers running on the same core.
I suggest referring to this MATLAB staff answer which provides two example scripts, “paralleltimertest_new.m” and “timerfun_new.m”, that achieve your desired functionality - https://www.mathworks.com/matlabcentral/answers/98271-how-can-i-create-timer-objects-which-are-running-in-parallel-in-matlab-7-13-r2011b.
Although the original answer was for R2011b, I verified that these scripts work correctly in R2019b.
You may also find the following related MATLAB Answers to be helpful:
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!