I have a matlab script (call that MyProcessing.m) that does some computations based on some random number. Right now I have a fixed seed to get the same sequence of random numbers. I would like to run this script multiple times in parallel to utilize the multiple cores that I have available on the system. I want each of the new "processes" to start with a different (but fixed for the moment) seed. Bellow is the processing file as it is right now.
There is a for loop inside the script but I cannot use parfor because each iteration depends on the previous one.
MyProcessing.m
rng(1);
A = rand(5,5);
x =[];
y = []
% for loop
% that updates x and y when necessary
% end for
figure(1);
scatter(x, y);
savefig(filename);
I have access to the Parallel Computing Toolbox in MATLAB but I cannot think on what I should do. I believe that I have to write another script to call the processing script with a different random seed but I want also the different processes to be run in parallel so that I can run many experiments.
EDIT:
I want something like
for i = 1:numberOfParallelProcesses
startANewRunOfTheScript();
end
where the for loop start the process and then it does not wait but it continues to start the next one.
parfeval? Just prefer functions before scripts. To make it simple, be sure to avoid shared data. I am not sure if paralellization can be done since you have internal dependencies, but since you sorted away this information as irrelevant I cannot say.forloop iteration depends on the previous iteration. But the whole algorithm is independent of another script running the same algorithm on the same data. What you suggested might work. I am going to find out how to use parfeval.