Disp Function with decimals
显示 更早的评论
My code runs but the decimals in disp function are getting multiplied by 1.0e+03 in comparision to the column run next to it
%%
%m=meters
Height=(0:20:300) ;
%P=kPa
%P=water pressure at the base of the water tower
%p=density of water(p=1000 kg/m^3)
%g=acceleration due to gravity(g=9.81 m/s^2)
p=1000;
g=9.81;
Pressure=((p.*g.*Height)./1000);
disp('Height(m) Pressure(kPa)')
disp([Height' Pressure'])
Pr15_2_nograph
Height(m) Pressure(kPa)
1.0e+03 *
0 0
0.020000000000000 0.196200000000000
0.040000000000000 0.392400000000000
0.060000000000000 0.588600000000000
0.080000000000000 0.784800000000000
0.100000000000000 0.981000000000000
0.120000000000000 1.177200000000000
0.140000000000000 1.373400000000000
0.160000000000000 1.569600000000000
0.180000000000000 1.765800000000000
0.200000000000000 1.962000000000000
0.220000000000000 2.158200000000000
0.240000000000000 2.354400000000000
0.260000000000000 2.550600000000000
0.280000000000000 2.746800000000000
0.300000000000000 2.943000000000000
回答(1 个)
Walter Roberson
2020-11-11
Include the command
format short g
before your disp()
类别
在 帮助中心 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!