Problem vertically aligning data in a table using fprintf
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm putting my meshgrid to a table and I'm trying to make it look more presentable. I can't seem to figure out how to get them to line up vertically. My current code is:
for i=1:11
fprintf('%2d %3.2f %3.2f %3.2f\n', t(i),X(i),X(i+11),X(i+22))
end
2 Kommentare
Akzeptierte Antwort
Walter Roberson
am 2 Okt. 2011
Do not put any spaces in your format. Instead, increase the "3" in your "%3.2f" to indicate the total number of characters to the right that you want the right edge of that column to be over by. For example, with %15.2f the right-hand side of the numbers would be the 15th character to the right of the previous column.
(Note: more characters will be used if required by the data value, such as if you were to try to print 1E42 with a 15-character fixed-point format.)
Weitere Antworten (1)
Image Analyst
am 2 Okt. 2011
Check your fonts: File/Preferences/Fonts. Maybe you're using a proportional font when you need a monospaced font.
Siehe auch
Kategorien
Mehr zu Data Types 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!