Matlab - setting up a nested parfor loop -
i got trouble setting parfor loop in matlab. know rather easy bit stuck here thats why appreciate help.
i have tried following
valuesform = zeros(901,100); valuesforopratio = zeros(100,1); counter=1; x = xlsread ('gtc.xlsx', 'a2:a10000'); y = xlsread ('gtc.xlsx','c2:c10000'); z = xlsread ('gtc.xlsx','b2:b10000'); parfor m = 100:1000; counter=counter+1 opratio = 1:100; npvtotal = cut_off_optimisation(m,opratio,x,y,z); valuesforopratio(opratio)=npvtotal; end valuesform(m-99,:) = valuesforopratio; end
and following error:
error using senitivity_script_10000_steps (line 10) error: variable valuesforopratio in parfor cannot classified.
how can fix ? lot.
edit
following commments advice tried following:
valuesform = zeros(901,100); x = xlsread ('gtc.xlsx', 'a2:a10000'); y = xlsread ('gtc.xlsx','c2:c10000'); z = xlsread ('gtc.xlsx','c2:c10000'); parfor m = 100:1000; npvtotal = cut_off_optimisation(m,1:100,x,y,z); valuesform(m-99,:) = npvtotal; end
which gives following error:
in assignment a(:) = b, number of elements in , b must same. error in parforscript (line 8) parfor m = 100:1000;
any idea how solve either of both problems?
as said in comments, since counter not required have removed , counter won't work because different iterations running in non sequential way , trying update same variable. not allowed.
next, have valuesforopratio = zeros(1,100)
inside parfor loop
because if put outside loop each iteration trying access same variable. not allowed. why getting error. when put inside, each iteration accessing locally created variable. reason why don't find in base workspace. here corrected code.
valuesform = zeros(901,100); x = xlsread ('gtc.xlsx', 'a2:a10000'); y = xlsread ('gtc.xlsx','c2:c10000'); z = xlsread ('gtc.xlsx','b2:b10000'); parfor m = 100:1000; valuesforopratio = zeros(1,100); opratio = 1:100; npvtotal = cut_off_optimisation(m,opratio,x,y,z); valuesforopratio(opratio)=npvtotal; end valuesform(m-99,:) = valuesforopratio; end
Comments
Post a Comment