How to enter the data into a excel and notepad that always start from a new line?

2 views (last 30 days)
For example, the first time I run the program and write a data in the excel or notepad file. Then I want to write the data in the same file with starting from a new line without overwrite the first result.
Here is the codes.
fid = fopen('serialno.txt', 'w'); % This portion of code writes the serial no.
fprintf(fid,'%s\n',serialno); % to the text file, if executed a notepad file with the
fclose(fid); % name serialno.txt will be open with the number plate written.
winopen('serialno.txt')

Answers (1)

dpb
dpb on 3 Apr 2015
fid=fopen('seralno.txt','a+');
See
doc fopen
for details.
  2 Comments
dpb
dpb on 4 Apr 2015
If the above solved your problem, please "Accept" the answer...
As for Excel, that's a horse of a Microsoft color...either use COM or xlswrite with a location(*); they're not sequential text files.
(*) I presume there's some method to find the first empty location if don't keep it externally, but that's an Excel question not Matlab and "I don't do Windows... :) " Look that up in the Help for COM or ask on an Excel newsgroup.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!