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.