I want to speed up my computations using parfor. I am using the code written below,
l=31:1:1000; % length-scale
sig2=6.5:0.1:10; % noise-variance
sigf2=1.3:0.1:10; % signal-variance
L=zeros(length(l),length(sig2),length(sigf2)); par=zeros(length(l),length(sig2),length(sigf2)); lsig2=length(sig2); lsigf2=length(sigf2); % cross-validation
parfor i=1:length(l) for j=1:lsig2 for k=1:lsigf2 par(i,j,k)=[l(i),sig2(j),sigf2(k)]; L(i,j,k)=kcrossval(Xtrain,ytrain,M,l(i),sig2(j),sigf2(k)); end end end but it is not working. I get error: Assignment has more non-singleton rhs dimensions than non-singleton subscripts.
When I remove the code
par(i,j,k)=[l(i),sig2(j),sigf2(k)];
it works but gives the following warning:
the entire array or struct 'sig2' is a broadcast variable. This might result in unnecessary communication overhead.
I have read the documentation but not able to find a solution. Please suggest the solutions.
Best Answer