How to display a table featuring user input
Afficher commentaires plus anciens
I'm working on a script (matlab book, pg. 216 question 32) in which a user will input temperatures and at the end of the script, it will find the heat capacity. I want to be able to display the user input (temperatures) along with displaying the heat capacity. Here is what my script is, I just don't know where to go next with adding the table.
Gas= menu('Please choose a gas from the following:','SO2','SO3','O2','N2');
switch Gas
case 1 %The following are the coefficients of the cubic equation for SO2%
a=38.91;
b=3.904*10^-2;
c=-3.105*10^-5;
d=8.606*10^-9;
case 2 %The following are the coefficients of the cubic equation for SO3%
a=48.50;
b=9.188*10^-2;
c=-8.540*10^-5;
d=32.40*10^-9;
case 3 %The following are the coefficients of the cubic equation for O2%
a=29.10;
b=1.158*10^-2;
c=-0.6076*10^-5;
d=1.311*10^-9;
case 4 %The following are the coefficients of the cubic equation for N2%
a=29.00;
b=.2199*10^-2;
c=-0.5723*10^-5;
d=-2.871*10^-9;
end
T=input('Please enter a temperature:');
i=1;
while i
yesorno=input('Is there an additional temperature needed (yes or no)?','s');
TF= strcmp (yesorno, 'yes');
if TF == 1;
i=i+1;
T(i)=input('Enter an additional temperature:');
else
break;
end
heatcapacity = a+(b*T)+((c*T).^2)+((d*T).^3);
end
disp(heatcapacity)
Réponses (1)
Walter Roberson
le 16 Déc 2013
fprintf('For temperature %f the heat capacity is %g\n', [T; heatcapacity]);
Catégories
En savoir plus sur Fluid Network Interfaces Library dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!