MATLAB Answers

Appending to text files

조회 수: 44(최근 30일)
alexander
alexander 12 Mar 2012
Hello, this is a fairly simple problem and i have come up with a simple enough solution. I need to append alot of text files to one master file.
i did this
clear all
clc
fid=fopen('t1.txt','a+');
fod=fopen('t2.txt');
while ~feof(fod)
fprintf(fid,'\n%s',(fgetl(fod)));
end
fclose('all');
Pretty simple right? It works well too. It appends everything in t2.txt to t1.txt. I have a suspision their is a better way to do this task though. The end of file identifier is what annoys me. Has anyone got a better way?

  댓글 수: 0

로그인 to comment.

답변 수 (1)

Walter Roberson
Walter Roberson 12 Mar 2012
short summary: feof() never predicts end of file.

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by