% Please use Octave version 4.0.0 (Code was executed on ubuntu platform)
% The code generates arff files for the dataset named train and test(features Tau and Pc removed)
% Please change directory in the code to your own

test_names = {'Test1.arff' 'Test2.arff' 'Test3.arff' 'Test4.arff' 'Test5.arff' 'Test6.arff' 'Test7.arff' 'Test8.arff' 'Test9.arff' 'Test10.arff'}; 
train_names = {'Train1.arff' 'Train2.arff' 'Train3.arff' 'Train4.arff' 'Train5.arff' 'Train6.arff' 'Train7.arff' 'Train8.arff' 'Train9.arff' 'Train10.arff'}; 

load test
load train

cd '/home/researcher/Desktop/arffs' % Change directory here
delete *.arff % Delete all the previously generated arff files

for i = 1:10
     
    st = num2str(i);
    s = strcat('NewFold', st);
    
    Data = [eval(s)]; % use string name to save cell array of same name into Data
    
    filename = fullfile('/home/researcher/Desktop/arffs',test_names{1,i}); % Change directory here
    fid = fopen(filename,'w');

    fprintf(fid,'@%s\r\n\r\n', 'relation Phosphoglycerylation');

    for l=1:size(Data{1,2},2)
    fprintf(fid,'@%s%d %s\r\n', 'attribute F',l,'numeric');
    end

    fprintf(fid,'@%s\r\n', 'attribute label {0,1}');

    fprintf(fid,'\r\n@%s\r\n', 'data');

    for j=1:size(Data,1)
    comma_sep = sprintf('%f,' , Data{j,2});
    fprintf(fid,'%s%s\r\n', comma_sep, Data{j,3});
    end
    fclose(fid)
    
    t = strcat('NewTrain', st);
    
    Data = [eval(t)]; % use string name to save cell array of same name into Data
    
    filename = fullfile('/home/researcher/Desktop/arffs',train_names{1,i}); % Change directory here
    fid = fopen(filename,'w');

    fprintf(fid,'@%s\r\n\r\n', 'relation Phosphoglycerylation');

    for m=1:size(Data{1,2},2)
    fprintf(fid,'@%s%d %s\r\n', 'attribute F',m,'numeric');
    end

    fprintf(fid,'@%s\r\n', 'attribute label {0,1}');

    fprintf(fid,'\r\n@%s\r\n', 'data');

    for j=1:size(Data,1)
    comma_sep = sprintf('%f,' , Data{j,2});
    fprintf(fid,'%s%s\r\n', comma_sep, Data{j,3});
    end
    fclose(fid)
end