% open the separate loss and win counts for different error measures
for errorCounter = 1:size(myErrorMeasures,2)
    % firstly open the required files
    eval(['myErrorMeasure' num2str(errorCounter) 'LossValues = fopen(''myErrorMeasure' num2str(errorCounter) 'LossValues.txt'', ''a'');']);
    eval(['myErrorMeasure' num2str(errorCounter) 'WinValues = fopen(''myErrorMeasure' num2str(errorCounter) 'WinValues.txt'', ''a'');']);
    
    %     eval(['fprintf([''' char(myErrorMeasures(errorCounter)) ''' ], myErrorMeasure' num2str(errorCounter) 'LossValues);']);
    %     eval(['fprintf([''' char(myErrorMeasures(errorCounter)) ''' ], myErrorMeasure' num2str(errorCounter) 'WinValues);']);
    
    for datasetCounter = 1:datasetSize
        eval(['fprintf(myErrorMeasure' num2str(errorCounter) 'LossValues,'''...
            char(myDatasets(datasetCounter)) ...
            ''');']);
        eval(['fprintf(myErrorMeasure' num2str(errorCounter) 'WinValues,'''...
            char(myDatasets(datasetCounter)) ...
            ''');']);
        for instanceCounter = 1:size(errorMeasureLossValues(errorCounter,datasetCounter,:),3)
            eval(['fprintf(myErrorMeasure' num2str(errorCounter) 'LossValues,'''...
                [ ',' num2str(errorMeasureLossValues(errorCounter,datasetCounter,instanceCounter))]   ...
                ''');']);
            eval(['fprintf(myErrorMeasure' num2str(errorCounter) 'WinValues,'''...
                [ ',' num2str(errorMeasureWinValues(errorCounter,datasetCounter,instanceCounter))]   ...
                ''');']);
        end
        eval(['fprintf(myErrorMeasure' num2str(errorCounter) 'LossValues,'''...
            '\n' ...
            ''');']);  % add new line at the end of every dataset
        eval(['fprintf(myErrorMeasure' num2str(errorCounter) 'WinValues,'''...
            '\n' ...
            ''');']);  % add new line at the end of every dataset
    end
    
    % lastly close the opened files
    eval(['fclose(myErrorMeasure' num2str(errorCounter) 'LossValues);']);
    eval(['fclose(myErrorMeasure' num2str(errorCounter) 'WinValues);']);
end
