parfor and persistent variables
4 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I have a matlab function that accepts a set of parameters say (query array), generates a unique input data (text) file and calls an external program to execute based on the generated input data file. The function then returns the results of the exe program. I would like to run this function as many times but also i would like to generate unique input files for each iteration (for instance X1.data, X2.data, X3.data,...) and I would like to keep track of the input parameters, generated data files and the function output.
The way that I do it, I use a for loop and define a persistent variable count inside the matlab function. Therefore, each time the function is called I assign a new integer (1, 2, 3,... to the generated date files e.g. X1.data X2.data, X3.data,...). In addition, I have a global stramwriter that writes the function input parameters and the the outputs into a text file one after each other.
I would like to use parfor for this exercise, however, I know that persistent variables will not be unique between the workers and also my global streamwriter would not work properly. Do you have any idea how to generate these unique data files and record the matlab function input-outputs using parfor?
I'd appreciate your comments.
0 件のコメント
回答 (1 件)
Walter Roberson
2017 年 6 月 1 日
If you have R2017a or later, consider using the new parallel data queue, perhaps together with afterEach
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Parallel for-Loops (parfor) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!