フィルターのクリア

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?

17 ビュー (過去 30 日間)
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.

採用された回答

Daniel LaCroix
Daniel LaCroix 2016 年 1 月 4 日
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);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by