Search code examples
matlabparallel-processingparfor

The variable `X` in a parfor cannot be classified in MATLAB


I have a parfor loop like this:

parfor i=1:20

for j=1:5
%% Some codes

[~,~,~,AUC]=perfcurve(testTargets,testOutputs,'1');

AUC_T(i)=AUC;

end

%% averaging between AUC_Ts in outputs of j=1:5

end

I have this error after running this code:

The variable AUC_T in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview".

I want store AUC values and use it afrer parfor loop. What is the problem and how can i solve it?

Thanks


Solution

  • I found the solution:

    parfor i=1:20
    
    for j=1:5
    %% Some codes
    
    [~,~,~,AUC]=perfcurve(testTargets,testOutputs,'1');
    
    AUC_T(i,j)=AUC;
    
    end
    
    end
    
    %% averaging between AUC_T values
    

    We should set averaging after parfor loop.

    Thank you Michael Graczyk for your commnet and answer.