How to store and retrieve multiple data sent from worker nodes to client node in MATLAB?

1 回表示 (過去 30 日間)
q = parallel.pool.DataQueue;
parfor i = 1:20
data = ['test - ', num2str(i)];
send(q,data);
end
This is the code I used to send data from the worker nodes to the client node. But I don't know if it helps me store the data I send from the workers to the client. The Queue length happens to be 20 which is correct but if it contains the data, I don't know how to retrieve it. I tried using a PollableDataQueue and poll() but it retrieves only one value which I guess is the last value.
So my questions are :
  • Is the method I'm using to store data sent from the workers correct?
  • If yes, how do I retrieve the stored data?
  • If no, how do I store data sent from the workers in the client?
  • Is the method I'm using to send data from the workers to the client correct?

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 28 日
  11 件のコメント
Viswanath Hariharan
Viswanath Hariharan 2017 年 10 月 30 日
Is there a way I can do this without relying on shared variables and nested functions? Because when I use this for my application, it produces a logical error that I am not able to clear.
Walter Roberson
Walter Roberson 2017 年 10 月 30 日
You should be able to push your parfor call into a function that you pass all appropriate variables to: indeed, isolating the parfor is recommended, as it can make it easier for the parser to classify the variables, by reducing the scope of what needs to be analyzed as possible inputs and outputs.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by