How can I copy lines of an external text file to another file
13 ビュー (過去 30 日間)
古いコメントを表示
回答 (2 件)
Voss
2022 年 4 月 26 日
Here's one way:
fid_in = fopen('a.txt'); % input file
fid_out = fopen('b.txt','w'); % output file
for ii = 1:4 % read (and discard) the first four lines
fgetl(fid_in);
end
data = fread(fid_in); % read the rest of the input file
fclose(fid_in); % close the input file
fprintf(fid_out,'%s',data); % write data to the output file
fclose(fid_out); % close the output file
type b.txt % check the contents of b.txt
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Naming Conventions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!