% Create the training corpus label vector Y = [repmat(-1,[1 500]), repmat(1,[1 500])]'; % Create the format vector for writing SVM data FMT=['%f',repmat(' %d:%f',[1 size(X_TRAIN,2)]), '\n']; % Open an output file, and write out data vectors using column-order fprintf fid=fopen('data1.txt','w'); for I=1:1000, fprintf(fid,FMT, Y(I), [1:size(X_TRAIN,2); X_TRAIN(I,:)]); end fclose(fid); % Read input from support_vectors.txt, delimited by colon or space A = textread('support_vectors.txt,'','whitespace',' :\b\t'); alpha=A(:,1); support_vectors=A(:,3:2:size(A,2));