[Solved] Matlab spilt one txt file to several files
This solution below should do the trick (at least it does for the simplified version you put above. fi = fopen(‘myFile.txt’,’r’); fileCount = 1; fo = fopen([‘output’,num2str(fileCount),’.txt’],’w’); header = fgets(fi); fprintf(fo,header); tline = header; first = true; mark_index = 8; while ischar(tline) if (~first) values = cell2mat(textscan(tline,’%f ‘)); if values(mark_index) == 1 fclose(fo); fileCount = … Read more