Parfor loop and eval statement

2 ビュー (過去 30 日間)
Chris
Chris 2012 年 3 月 15 日
編集済み: John Kelly 2014 年 5 月 27 日
I have a parfor loop but have a eval statement basically importing stats from data files on my c drive into a list of variable names (player names) that I have in an array. Right now it executes with a regular loop but the data function takes a significant amount of time to read one by one. When I look at my cpu resources it is only about 20% max in use and I am hoping a parfor loop could speed up this process by allowing multiple file reads (especially since each read would be a different file). I tried creating a function but I can't figure out how to get the function to return a variable rather than a value. Probably by design but I realize the variables created in the function once ended are no longer seen by the main for loop that calls the function. Is there a way for the function to use the eval statement to save the variables either globally or say add to a mat file.
  1 件のコメント
Jan
Jan 2012 年 3 月 15 日
Please post the code you are using.

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

採用された回答

Jason Ross
Jason Ross 2012 年 3 月 15 日
編集済み: John Kelly 2014 年 5 月 27 日
Have you looked at the spmd construct rather than parfor? It allows you to do this kind of thing much more easily
In that doc page, there are links to "Interlab Communication Within a Communicating Job" and "Distributed and Codistributed Arrays", which tell you how to set up communications between the labs and move data around.

その他の回答 (1 件)

Jan
Jan 2012 年 3 月 15 日
Using eval to create variables is a bad idea. Please search in this forum for hundreds of related threads.

カテゴリ

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