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
Walter Roberson 2020년 11월 11일

0 개 추천

Include the command
format short g
before your disp()

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

질문:

2020년 11월 11일

답변:

2020년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by