The outputs from the PARFOR loops must be either reduction variables (for example, summation calculation) or βchoppedβ. See this page in the document for details.
In your case, you are trying to generate a βclippedβ output, but your indexing expression is too complicated for PARFOR. In PARFOR, chopped output must be indexed: a loop variable for one index and some constant expression for other indices. The constant expression must be either : end , or a literal. The following example shows several cut outputs:
x3 = zeros(4, 10, 3); parfor ii = 1:10 x1(ii) = rand; x2(ii,:) = rand(1,10); x3(:,ii,end) = rand(4,1); x4{ii} = rand(ii); end
In your case, your indexing expression in Ad is too complicated to handle PARFOR. Probably the easiest thing you can do is return the calculations as an array of cells and then enter them in Ad on the host side using a regular FOR loop, for example:
parfor i = 1:length(con) tmpout{i} = ....; end for i = 1:length(con) Ad(...) = tmpout{i}; end
source share