gerard@1: % Copyright 2013 MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA gerard@1: % gerard@1: % Written by Gerard Roma gerard@1: % gerard@1: % This program is free software: you can redistribute it and/or modify gerard@1: % it under the terms of the GNU Affero General Public License as published by gerard@1: % the Free Software Foundation, either version 3 of the License, or gerard@1: % (at your option) any later version. gerard@1: % gerard@1: % This program is distributed in the hope that it will be useful, gerard@1: % but WITHOUT ANY WARRANTY; without even the implied warranty of gerard@1: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the gerard@1: % GNU Affero General Public License for more details. gerard@1: % gerard@1: % You should have received a copy of the GNU Affero General Public License gerard@1: % along with this program. If not, see . gerard@1: gerard@1: function make_list_files gerard@1: NUM_FOLDS = 5; gerard@1: classes = {'bus' 'busystreet' 'office' 'openairmarket' 'park' 'quietstreet' 'restaurant' 'supermarket' 'tube' 'tubestation'}; gerard@1: [names,labels] = get_filenames('path_to_files'); gerard@1: cp = cvpartition(labels,'k',NUM_FOLDS); gerard@1: for i = 1:NUM_FOLDS gerard@1: tr_fnames = names(cp.training(i)); gerard@1: tr_classes = labels(cp.training(i)); gerard@1: te_fnames = names(cp.test(i)); gerard@1: te_classes = labels(cp.test(i)); gerard@1: train_filename = strcat('fold',num2str(i),'_train.txt'); gerard@1: train_fid = fopen(train_filename,'w+'); gerard@1: for j = 1:length(tr_fnames) gerard@1: fprintf(train_fid,'%s\t',char(tr_fnames(j))); gerard@1: fprintf(train_fid,'%s\n',char(classes(tr_classes(j)))); gerard@1: end gerard@1: fclose(train_fid); gerard@1: gerard@1: test_filename = strcat('fold',num2str(i),'_test.txt'); gerard@1: test_fid = fopen(test_filename,'w+'); gerard@1: gt_filename = strcat('fold',num2str(i),'_gt.txt'); gerard@1: gt_fid = fopen(gt_filename,'w+'); gerard@1: for j = 1:length(te_fnames) gerard@1: fprintf(test_fid,'%s\n',[char(te_fnames(j))]); gerard@1: fprintf(gt_fid,'%s\t',[char(te_fnames(j))]); gerard@1: fprintf(gt_fid,'%s\n',[char(classes(te_classes(j)))]); gerard@1: end gerard@1: fclose(gt_fid); gerard@1: fclose(test_fid); gerard@1: gerard@1: end