Print table to text file
32 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Sruthi Geetha
on 25 Jan 2018
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
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!