Print table to text file
34 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Sruthi Geetha
le 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 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!