Print table to text file
조회 수: 25 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!