How to stop displaying scientific notation
This calculates a couple different things and I want the answers to be up to 3 decimal places.
prompt = 'Time of flight?(s) ';
t = input(prompt);
if (t <= 45)
h = 15*t.^2;
fprintf('Altitude: %dm\n\n', h)
v = 30*t;
fprintf('Velocity: %dm/s\n\n', v)
if (h <= 11000)
T = (h - 44332.30769230768) / -153.84615384615378;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(-6.5e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(-6.5e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 25000)
T = 216.66;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(1*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(1*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 47000)
T = (h + 47220) / 333.3;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(3e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(3e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 53000)
T = 282.66;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(1*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(1*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 79000)
T = (h - 115813) / -222.2;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(-4.5e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(-4.5e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 90000)
T = 165.66;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(1*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(1*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 110000)
T = (h - 48585) / 250;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(4e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(4e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
end
elseif (t < 117.5)
h = 30375 + (1350*t) + 0.5*(-11.5)*t.^2;
fprintf('Altitude: %dm\n\n', h)
v = 1350 - 11.5*t;
fprintf('Velocity: %dm/s\n\n', v)
if (h <= 11000)
T = (h - 44332.30769230768) / -153.84615384615378;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(-6.5e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(-6.5e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 25000)
T = 216.66;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(1*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(1*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 47000)
T = (h + 47220) / 333.3;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(3e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(3e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 53000)
T = 282.66;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(1*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(1*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 79000)
T = (h - 115813) / -222.2;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(-4.5e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(-4.5e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 90000)
T = 165.66;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(1*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(1*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
elseif (h <= 110000)
T = (h - 48585) / 250;
fprintf('Temperature: %dk\n\n', T)
P = 101.325*(T/273.15).^(-9.81/(4e-3*287));
fprintf('Pressure: %dkPa\n\n', P)
rho = 1.225*(T/273.15).^-((9.81/(4e-3*287))+1);
fprintf('Density: %dkg/m^3\n\n', rho)
end
end
0 个评论
回答(1 个)
0 个评论
另请参阅
类别
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!