I wished to write the below code in parallel:
min=0;
LB=[min1 min2]
UB=[max1 max2]
numvalues2=OpParam(2);
for i =LB(1):step1:UB(1),
for j =LB(2):step2:UB(2)
acc=ComputeCbetaPerm( [i j],featureMatrix,labelMatrix);
if(acc < max)
acc=min;
values=[i j];
end
end
end
I Changed to the below to avoid the use of temporary variable max but still it gives an error of classification which I don't get.
LB=[min1 min2]
UB=[max1 max2]
Result=cell(numvalues1,numvalues2,1);
outervalues=LB(1):step1:UB(1);
innervalues=LB(2):step2:UB(2);
for (i =1:numel(outervalues)),
parfor (j =1:numel(innervalues)),
acc=ComputeCbetaPerm( [outervalues(i) innervalues(j)],featureMatrix,labelMatrix);
Result(i,:,1)={outervalues(i),innervalues(j),acc};
end
end
Asked also at http://in.mathworks.com/matlabcentral/answers/195799-classification-error-for-parfor.
EDIT:
Subscripted assignment dimension mismatch.
Caused by: Subscripted assignment dimension mismatch.
j
ans =
0.0000 + 1.0000i
parforwith aforand run the code. There is something wrong with the indices asResult(1,:,1)is written multiple times. - DanielLB(1):((UB(1)-LB(1))/(numvalues1 -1)):UB(1)withlinspace- DanielResult(i,j,1)- Abhishek Bhatia