Error: Contour endpoints and waypoints must be finite.

2 vues (au cours des 30 derniers jours)
Steven
Steven le 6 Déc 2012
I'm trying to write a function to plot the Cp of a compound, and I keep getting this error when I try to intergrate. I'm using the 2012 version of matlab.
function outputValue=Cps()
Pc=4550;
Tc=654;
b = .092968;
w = .22894;
k = 0.37464 + 1.54226*w - 0.26992*w^2;
R = 8.314;
Ai = 112.057;
Bi = -0.8324;
Ci = 0.002865;
Di = -0.000003;
v = [];
T = [300:1:1000];
Cp = [];
Cpi = [];
Cv = [];
dPdT = [];
dPdV = [];
alpha= []
P = [.02.*Pc .5.*Pc Pc 2.*Pc];
for s = 1:4
for t = 1:length(T)
alpha(t) = (1+k.*(1-sqrt(T(t)./Tc))).^2;
a = (.45724.*(R.*Tc).^2.*alpha(t))./Pc;
A = (a.*P(s))./(R.^2.*t.^2);
B = (P(s).*b)./(R.*t);
Z = [1 -(1-B) (A-3.*B-2.*B) -(A.*B-B.^2-B.^3)];
r =roots(Z);
for i = 1:3
if ((imag (Z(i))~=0))
Z(i)=0;
end
end
G(t) = max(r);
v(t) = (G(t).*R.*t)./P(s);
Cpi(t) = Ai + Bi.*T(t) + Ci.*T(t).^2 + Di.*T(t).^3;
C = ((k^2+k)./(2.*sqrt(Tc)));
SecondDerivative = @(x) ((a.*C.*(1/T(t).^1.5))./(x.*(x+b)+b.*(x-b)));
dPdT(t) = (R./(v(t)-b))-a.*(k.*sqrt(alpha(t)./(T(t).*Tc))./(v(t).*(v(t)+b)+b.*(v(t)-b)));
dPdV(t) = (-R.*T(t)/(v(t)-b).^2)+((2.*a.*(v(t)+b))./((v(t).*(v(t)+b)+b.*(v(t)-b))).^2);
Cv(t) = (Cpi(t)-R) + (T(t).*integral(SecondDerivative,Inf,v(t)));
Cp(t) = Cv(t) - (T(t).*v(t).*(dPdT(t)).^2)./dPdV(t);
end
end
plot(T,Cp,'-g')

Réponses (1)

Sean de Wolski
Sean de Wolski le 6 Déc 2012
Modifié(e) : Sean de Wolski le 6 Déc 2012
It looks like it's complaining about this line:
Cv(t) = (Cpi(t)-R) + (T(t).*integral(SecondDerivative,Inf,v(t)));
because it does not like the Inf as the minimum boundary, xmin! This makes sense.
doc integral
For more information.
Also as an FYI, it typically pays to paste the full eror message. The error messages contain diagnostic information like line numbers and the stack that make it much easier to debug.
  2 commentaires
Steven
Steven le 6 Déc 2012
Error using integralCalc (line 35) Contour endpoints and waypoints must be finite.
Error in integral (line 89) Q = integralCalc(fun,a,b,opstruct);
Error in Cps (line 41) Cv(t) = (Cpi(t)-R) + (T(t).*integral(SecondDerivative,Inf,v(t)));
Does that help?
Sean de Wolski
Sean de Wolski le 6 Déc 2012
So it's exactly where I predicted it would be. Don't use Inf as xmin.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by