parfor and persistent variables
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 1 Jun. 2017
If you have R2017a or later, consider using the new parallel data queue, perhaps together with afterEach
0 Kommentare
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) 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!