Info

此问题已关闭。 请重新打开它进行编辑或回答。

Table format issue with fprintf command

1 次查看(过去 30 天)
Logan Keener
Logan Keener 2019-11-1
关闭: MATLAB Answer Bot 2021-8-20
I run this code and the tables read left to right instead of running vertically
r=0:0.25:3;
S=4*pi*r.^2;
V=(4/3)*pi*r.^3;
disp(' Radius, r(in) Surface Area, S(in^2) Volume, V(in^3)')
fprintf('%9.2f in%9.2f in^2%9.2f in^3\n',[r',S',V']);
Radius, r(in) Surface Area, S(in^2) Volume, V(in^3)
0.00 in 0.25 in^2 0.50 in^3
0.75 in 1.00 in^2 1.25 in^3
1.50 in 1.75 in^2 2.00 in^3
2.25 in 2.50 in^2 2.75 in^3
3.00 in 0.00 in^2 0.79 in^3
3.14 in 7.07 in^2 12.57 in^3
19.63 in 28.27 in^2 38.48 in^3
50.27 in 63.62 in^2 78.54 in^3
95.03 in 113.10 in^2 0.00 in^3
0.07 in 0.52 in^2 1.77 in^3
4.19 in 8.18 in^2 14.14 in^3
22.45 in 33.51 in^2 47.71 in^3
65.45 in 87.11 in^2 113.10 in^3
The left column is supposed to be 0, .25, .5, etc. but instead it goes to the left column, does anyone know how to fix this?

回答(0 个)

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by