matlab未定义函数或变量(附上源代码)
定义函数1:cal_Vfunction[v,Z]=cal_V(p,T,R,Tca,Pca,wa,Tc32,Pc32,w32,percent,liq)%计算方程中的常系数T...
定义函数1:cal_Vfunction [ v,Z ] = cal_V( p,T,R,Tca,Pca,wa,Tc32,Pc32,w32,percent,liq )%计算方程中的常系数Tra = T/Tca;aa = 0.45724*R^2*(Tca)^2/(Pca)*(1+(0.37464+1.54226*wa-0.26992*wa^2)*(1-Tra^0.5))^2;ba = 0.07780*R*Tca/(Pca);Tr32 = T/Tc32;a32=0.45724*R^2*(Tc32)^2/(Pc32)*(1+(0.37464+1.54226*w32-0.26992*w32^2)*(1-Tr32^0.5))^2;b32 = 0.07780*R*Tc32/(Pc32);a = (1-percent)*(1-percent)*aa + 2*percent*(1-percent)*sqrt(aa*a32) + percent*percent*a32;b = (1-percent)*ba + percent*b32;%根据P-R方程算比体积f = p - R*T/(v-b)+a/(v*(v+b)+b*(v-b));v = solve(f);v = real(vpa(v,5));if(liq)v = vpa(min(v),5);Z = p*v/R/T;elsev = vpa(max(v),5);Z = p*v/R/T;end主程序:%R32相关参数Pc32 = 5.78e6;Tc32 = 351.26;w32 = 0.277;M32 = 52.02;Rg32 = 8314/M32;%R134a相关参数Pca = 4.05e6;Tca = 374.11;wa = 0.326;Ma = 102.03;Rga = 8314/Ma;T = 310;R = 8.314;for k = 1:21xR32 = 0+(k-1)*0.05;sigmaY = 2;p = 0.5e6;j = 0;while(abs(sigmaY)-1>0.001)yR32 = 0;[ vl,Zl ] = cal_V( p,T,R,Tca,Pca,wa,Tc32,Pc32,w32,xR32,1 );[ vv,Zv ] = cal_V( p,T,R,Tca,Pca,wa,Tc32,Pc32,w32,yR32,0 );[ Phial,Phi32l ] = cal_Phil( Zl,xR32,p,T,R,Tca,Pca,wa,Tc32,Pc32,w32 );[ Phiav,Phi32v ] = cal_Phiv( Zv,yR32,p,T,R,Tca,Pca,wa,Tc32,Pc32,w32 );k1 = Phial/Phiav;k2 = Phi32l/Phi32v;sigmaY(1) = k1*(1-xR32)+k2*xR32;i = 1;while 1yR32 = k2*xR32/sigmaY(i);[ Phiav,Phi32v ] = cal_Phiv( Zv,yR32,p,T,R,Tca,Pca,wa,Tc32,Pc32,w32 );k1 = Phial/Phiav;k2 = Phi32l/Phi32v;sigmaY(i+1) = k1*(1-xR32)+k2*xR32;if(abs(sigmaY(i+1)-sigmaY(i))<0.001)sigmaY = sigmaY(i+1);break;endi = i+1;endj = j+1;p = (0.5+j*0.01)*1000000;endresultP(k) = p;resultyR32(k) = yR32;endxR32 = 0:0.05:1;plot(xR32,resultP,'bo-',resultyR32,resultP,'k+-')title('T=310K,R32+R134a泡点压力与成分')xlabel('R320液(汽)相摩尔分数x(y)')ylabel('压力P(pa)')legend('R32x','R32y')运行后出现:未定义函数或变量 'cal_V'。并且在定义的第一个函数上中,有一个v,系统提示
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询