dlmwrite does not append to file

6 Ansichten (letzte 30 Tage)
Bob Thompson
Bob Thompson am 12 Mär. 2021
Kommentiert: Bob Thompson am 12 Mär. 2021
I am writing headers and data to a text file, and I am able to write the headers using fprintf, so I know my filepath is correct, but my dlmwrite command will not append the data to the file.
fprintf(ffile,'%s %s %s %s %s\n',headers{:});
dlmwrite(fullfileout,outmatrix,'-append','precision','%$.8f');
I believe this was written in 2016 or 2017 MATLAB, and I am now using 2019b. Was there a change to dlmwrite that I need to update?
No error message is received, the files just end up only including the header. outmatrix is not empty, and the code has worked in the past without any changes.
I know that dlmwrite has been replaced with writematrix, but version 2019b doesn't support the 'WriteMode','append' options in writematrix.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 12 Mär. 2021
The error I see is due to the dollar sign in your precision. Remove that, and it prints the numbers in the desired format.
The dollar sign represents the identifier, and should be preceded by a number to work as designed. See here.
  1 Kommentar
Bob Thompson
Bob Thompson am 12 Mär. 2021
Thanks, that does seem to have fixed it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by