function svecs=svmExtractSupportVectors(model_file) % returns the support vector ids fd = fopen(model_file,'r'); fltingpt = '[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?'; ptrn = ['^(' fltingpt ')(\s+\d+:' fltingpt ')+?\s*#(.*?)\s*$']; svecs=[]; ii=1; while 1 tline = fgetl(fd); if ~ischar(tline), break, end match=regexp(tline,ptrn,'tokens'); if length(match)==1 && length(match{1})==3 %svecs(end+1) = str2num(match{1}{3}); %fprintf('%d %s\n',ii,str2num(match{1}{3})); ii=ii+1; svecs(end+1) = ii; ii=ii+1; end end fclose(fd); svecs = sort(svecs);