Undefine function or variable

4 Ansichten (letzte 30 Tage)
Chinaemerem Valentine Nwobi
Beantwortet: Dennis am 8 Mai 2019
%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

Antworten (1)

Dennis
Dennis am 8 Mai 2019
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

Kategorien

Mehr zu Propulsion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by