0

次のような raw.txt ファイルがあります。

#   Angle   Data A       DATA B     ...       
1   45    1440.352365   3.619902121
2   45    1440.352365   3.619902121
3   45    1440.192496   3.632952692
1   45    1440.192496   3.632952692
2   45    1440.192496   3.632952692
3   45    1440.192496   3.632952692
4   45    1440.192496   3.632952692
.
.
.

最初の行 (#) は 3 の後に繰り返されます。4、5、6 に移動する必要があります... その行のみを変更し、残りはそのままにしておくスクリプトを書きたいと思います。私はこのようなものを書いていましたが、私たちの理解できないエラーが発生しました

   function TrailRestFix(filename)

infile = fopen(filename, 'r');
outfile = fopen(filename, 'w');
i = 0;
while ~feof(infile)
    line = fgets(infile);
    space_idx = strfind(line, ' ');
    if i == 0
        fprintf(outfile,'%s',line);
    else
        fprintf(outfile,'%i %s',i,line(space_idx(1)+1:end));
    end
    i = i + 1;
end
fclose(infile);
fclose(outfile);

end
4

0 に答える 0