effort:
function [Cp]= hcap_LRb(T,g)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
g=char('SO2','SO3','O2','N2');
if 'SO2';
a=38.91;
b=3.904e-2;
c=-8.540e-5;
d=32.40e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
if 'SO3';
a=48.50;
b=9.188e-2;
c=-8.540e-5;
d=32.40e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
if 'O2';
a=29.10;
b=1.158e-2;
c=-.6076e-5;
d=1.311e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
if 'N2';
a=29.00;
.2199e-2;
c=.5723e-5;
d=-2.871e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
end
end
end
end
while 20<=T<=300
T=[10,20,50,250,400];
disp('The heat capacity for g is Cp in J.(g*mole*deg C)')
if T<20||T>300;
Cp=disp('Temperature entered is outside the range. Temp must be between 20 and 300 deg C.');
end
end
end
problem: I only receive one set of answers, it is for N2.
The problem says to display in the Command Window the function output for SO3 and N2 at the following temperatures of 10 deg C, 20 deg C, 50 deg C, 250 deg C, and 400 deg C. However, why do I need the info for SO2 and O2 if I only need So3 and N2 as my outputs?
function [Cp]= hcap_LRb(T,g)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
g=char('SO2','SO3','O2','N2');
if 'SO2';
a=38.91;
b=3.904e-2;
c=-8.540e-5;
d=32.40e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
if 'SO3';
a=48.50;
b=9.188e-2;
c=-8.540e-5;
d=32.40e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
if 'O2';
a=29.10;
b=1.158e-2;
c=-.6076e-5;
d=1.311e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
if 'N2';
a=29.00;
.2199e-2;
c=.5723e-5;
d=-2.871e-9;
Cp=a+b*T+c*(T.^2)+d*(T.^4);
end
end
end
end
while 20<=T<=300
T=[10,20,50,250,400];
disp('The heat capacity for g is Cp in J.(g*mole*deg C)')
if T<20||T>300;
Cp=disp('Temperature entered is outside the range. Temp must be between 20 and 300 deg C.');
end
end
end
problem: I only receive one set of answers, it is for N2.
The problem says to display in the Command Window the function output for SO3 and N2 at the following temperatures of 10 deg C, 20 deg C, 50 deg C, 250 deg C, and 400 deg C. However, why do I need the info for SO2 and O2 if I only need So3 and N2 as my outputs?