フィルターのクリア

Print table to text file

25 ビュー (過去 30 日間)
Kellerautomat
Kellerautomat 2018 年 1 月 16 日
回答済み: Sruthi Geetha 2018 年 1 月 25 日
Hi everyone, I'm trying to print a table which I created to an existing text file
I'm aware that a table is not a char and therefore the fprint does not work, but I really don't know how I could save the table to my file... I'd be glad if someone could help me! Thanks in advance!
if true
tableT=table(Number,Response,Time,Date);
structtableT(1,1).Number=num;
structtableT(1,1).Response='correct';
structtableT(1,1).Time=time;
structtableT(1,1).Date=date;
tableT=[tableT;struct2table(structtableT)];
fid = fopen(file, 'a+');
fprintf(fid, '\n%s', tableT);
fclose(fid);
end

回答 (1 件)

Sruthi Geetha
Sruthi Geetha 2018 年 1 月 25 日
You can use the 'writetable' function to write a table to a text file. The syntax is: writetable(T,filename) where T is the table and filename is the name of file with extension. The extension must be one of the following: .txt, .dat, or .csv for delimited text files .xls, .xlsm, or .xlsx for Excel spreadsheet files .xlsb for Excel spreadsheet files supported on systems with Excel for Windows

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by