Matlab Parallel toolbox: Error with parfor -
Matlab Parallel toolbox: Error with parfor -
i wrote code following
.... index = 1; parfor mi=initmu:maxmu la1i=initla+1:(maxla-initla)/stepla+1 imaged=uint8(gausspoisondenoise(image, mu(mi), la1(la1i), la2(la1i))); p = psnr(imaged, image0); index=index+1; end end ....
but matlab tells me "parfor loop cannot run due way variable index used". mean? need do?
the parfor loop separates loop run different loop-iteration @ same time in arbitrary order.
the problem variable "index" increment @ same time in different iteration , different values.
for illustration while 1 matlab-worker computing iteration mu=2 , increasing index 3, computing iteration mu=10 , increasing index one. in case effective value of index? (index+3 or index+1?)
you cannot utilize parfor when iteration in loop depends on result of other iteration.
if need "index" count number of iteration, think can calculate operating on intmu, maxmu, intla, maxla, stepla. (but have pourpose!)
matlab
Comments
Post a Comment