How to pass data between parallel tasks that don't terminate?
5 次查看(过去 30 天)
显示 更早的评论
I have a data logging & monitoring tool that I've written using the App Designer. It creates a timer object in the background to retrieve data, saves it to a file, and updates the display. Since it's a single-threaded application, I can't save data any faster than I can update the display (which is rather slow). Because of this, my timer can't run faster than about 1x per second. Ideally, I'd like to save data to the file at 10-100x per second, even if the display updates more slowly.
I have the parallel computing toolbox, so I've been looking at running the data collection and plotting as parallel tasks. The app display would refresh using a timer as it does today, but the data collection would run as a background parallel task continuously sampling data (while(1)) as fast as possible.
It appears that the branch and parpool functions both require you to wait until a task is complete before accessing its data. Since the data collection task never ends, I'm not sure what to do.
In summary, here's what I'm looking for:
- Data collection task - Runs continuously, appends readings to DATA matrix, writes to output file
- Screen update task - Runs 1/sec, only displays the latest value from DATA matrix
0 个评论
回答(1 个)
Sid Jhaveri
2016-12-6
If waiting till task is completed is the only issue while using Parallel Computing Toolbox, then you can try using " parfeval " or " parfevalOnAll " functions of Parallel Computing Toolbox.
To learn more about asynchronous parallel programming in MATLAB, refer to the link given below: https://www.mathworks.com/help/distcomp/asynchronous-parallel-programming.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!