How do I create a tab delimited text file with headers that can be appended every time I run a code I have previously written?

16 visualizaciones (últimos 30 días)
I am trying to write a new script that creates (with headers) and then appends a text file with numbers outputted from variables in another code I have previously written. An example of the output I am looking for would be:
Serial Number Radial Dev RadialOver Ecc TanDev
S001 123 456 78 90
S002 ... ... ... ...
S003 ... ... ... ...
S004 ... ... ... ...
Wherein everytime I call the script, it will add a new line with the values I am calling. Not as familiar with this part of Matlab as I probably should be, any help would be appreciated.

Respuesta aceptada

Daniel LaCroix
Daniel LaCroix el 4 de En. de 2016
Each time you want to write to a text file, open it with fopen and record the file id MATLAB assigns it. Then use fprintf (hopefully you've used this before) to write to the file, using the file id to tell MATLAB to write to the text file, not the command window. Then close the file to make MATLAB happy.
fid=fopen('stuff.txt','a'); %the 'a' grants append only write access
fprintf(fid,'formatted stuff, use \t for making a table');
fclose(fid);

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by