Undefine function or variable
1 回表示 (過去 30 日間)
古いコメントを表示
%Am experiencing problems running this file, please find the the input data
.%%
%%
%propanes critical temperature and pressure and accentric factor
Tc=369.9;
Pc=42.0;
Omega=0.152;
%%
%universal gas constant
R=83.14;
% b and m for the PR EOS
b=0.7780*R*Tc/Pc;
m=0.37464+1.54226*Omega-0.26992*Omega^2;
j=1;
for i=40:10:90
%molar volume
v=0.001:1:2500;
%temperature
T(i)=273.15+i;
%reduced temperature
Tre=T(i)/Tc;
%a for the PR EOS
a = 0.45724*(R*Tc)^2/Pc*(1+m*(1-sqrt(Tre)))^2;
%PR EOS
P=R*T(i)./(v-b)-a./(v.*(v+b)+b*(v-b));
Pv=[Pv P'];
%plotting isotherms for T varying from 313.15 to 363.15
h=plot(v,P);
set(h,'color',rand(1,3),'linewidth',2);
hold on
axis ([0 1600 -40 60])
xlabel('volume in cm3/mol')
ylabel('pressure in bar')
title ('isotherm for propane')
end
0 件のコメント
回答 (1 件)
Dennis
2019 年 5 月 8 日
In general you are more likely to receive an answer if you describe the problem you are facing and include any error messages. In this case 'Undefined function or variable 'Pv'.', caused by
Pv=[Pv P'];
To fix it you need to declare Pv before using it.
Tc=369.9;
Pc=42.0;
Omega=0.152;
%%
%universal gas constant
R=83.14;
% b and m for the PR EOS
b=0.7780*R*Tc/Pc;
m=0.37464+1.54226*Omega-0.26992*Omega^2;
j=1;
Pv=[];
for i=40:10:90
%molar volume
v=0.001:1:2500;
%temperature
T(i)=273.15+i;
%reduced temperature
Tre=T(i)/Tc;
%a for the PR EOS
a = 0.45724*(R*Tc)^2/Pc*(1+m*(1-sqrt(Tre)))^2;
%PR EOS
P=R*T(i)./(v-b)-a./(v.*(v+b)+b*(v-b));
%plotting isotherms for T varying from 313.15 to 363.15
h=plot(v,P);
set(h,'color',rand(1,3),'linewidth',2);
hold on
axis ([0 1600 -40 60])
xlabel('volume in cm3/mol')
ylabel('pressure in bar')
title ('isotherm for propane')
end
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!