How to pass data between parallel tasks that don't terminate?

4 Ansichten (letzte 30 Tage)
Scott Waun
Scott Waun am 2 Dez. 2016
Kommentiert: Scott Waun am 6 Dez. 2016
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

Antworten (1)

Sid Jhaveri
Sid Jhaveri am 6 Dez. 2016
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
  1 Kommentar
Scott Waun
Scott Waun am 6 Dez. 2016
Is it possible to access the function's internal variables before it's completed execution? In my case, the function will never end (endlessly collecting data). The parallel thread needs to be able to access its data however. The examples only show a for loop that waits for outputs to become available on completion.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by