getting results after a code with a smpd block
Show older comments
Hello, I have a question about how to use smpd. I am doing a stochastics simulation.I am runing it in a mahcine with 4 cores. The main script call a function as:
smpd
function [output1,ouput2]=myfun();
end
where myfun is my main code.
So for each output I got a composite var for example (output1, compossite 1x4).
Then to get the values of the var I can use a loop to go through every worker or I can just collect without loop as:
output1c = output1 (1,1);
output2c = output1 (1,2);
output3c = output1 (1,3);
output4c = output1 (1,4);
where output(1,2,3,4)c are the variables that I used as results .
My questions are:
1- Since smpd run the same code in each worker, the 4 output(1,2,3,4)c are independents aoutputs of the same code ?
2- Some times happen that If I run the same code different times I got the same result,since I have a stochastic code every run should be different , I found that is a problem of collecting the results from the workers, could be possible that the workers kept the old results and I not deleting properly , I am using, clear all.
Thank you very much , and I am sorry if I am not clear enough
Answers (1)
Edric Ellis
on 6 Mar 2018
0 votes
- Yes, each output is the result of an independent run of myfun
- Be aware that MATLAB intializes the random state in a deterministic way. See this documentation page for more details.
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!