print table using printf
31 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Metin Akyol
am 17 Feb. 2022
Beantwortet: Chunru
am 18 Feb. 2022
Is there an elegant way to print the content from a table using fprintf?
Right now, I am printing the columns one at a time, underneath each other (into a csv file). I would like print it to a csv file however in the original order with the columns next to each other.
1 Kommentar
Voss
am 17 Feb. 2022
writetable() may work for what you are trying to do, but if you must use fprintf(), then it may be convenient to convert the table to another data type first using, e.g., table2array() or table2cell().
Akzeptierte Antwort
Chunru
am 18 Feb. 2022
a = array2table(rand(4,3)); % a simple table
s = formattedDisplayText(a); % formatted display
fid = fopen('test.csv', 'w');
fprintf(fid, s);
fclose(fid);
type test.csv
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!