MATLAB
目标:做一个app,输入参数自动判别求解x(保温层外表面温度WBT)
在linshi2.m运行可求解,在app内部使用时x=vpasolve(app.BSR==app.GSR);
出现错误使用 sym/vpasolve (line 145)Unable to find variables in equations.
syms x
%棕色内容为通过输入参数进行判别,带入公式,部分公式中含有未知量x
app.C1=5.67;
%P-T对应
app.data=xlsread('C:\Users\Sheji\Desktop\气泡计算APP\饱和蒸汽压力温度对应表-详细版.xlsx','Sheet1','A2:B293');
for n=1:1:292
if app.YL+0.1==app.data(n,1)
app.ZWD=app.data(n,2);
end
end
%辐射换热系数计算
app.CFS=(app.BH+1)./2*app.C1*(((273+x)./100)^4-((273+app.HJT)./100)^4)/(x-app.HJT);
%保温外径
app.BWJ=app.QWJ+2*app.HD;
%WD1值计算
app.WD1=app.FS*app.BWJ;
%对流换热系数-室外
if app.WD1>0.8
app.DLCW = 4.53*app.FS^0.805./app.BWJ^0.195;
else
app.DLCW = 0.08./app.BWJ+4.2*app.FS^0.618./app.BWJ^0.382;
end
%对流换热系数-室内
app.DLCN=26.4./(297-0.5*(x+app.HJT))^0.5*((x-app.HJT)./app.BWJ)^0.25;
%对流换热系数
if app.HJ==1
app.DL=app.DLCN;
elseif app.HJ==2
app.DL=app.DLCW;
end
%表面换热系数
app.BM=app.CFS+app.DL;
%筒体温度
app.TTT=app.ZWD;
%保温层导热系数
if app.CZ==1
app.DR=2.306;
elseif app.CZ==2
app.DR=0.4;
elseif app.CZ==3
app.DR=0.9;
elseif app.CZ==4
app.DR=0.054+0.272*((app.TTT+x)./2./1000)^2;
end
%保温层散热量
app.BSR=2*pi*app.DR*(app.TTT-x)./log(app.BWJ./app.QWJ);
%金属外壁对空气放热系数
app.BFR=app.BM;
%金属管外壁与外界散热量
app.GSR=app.BFR*(x-app.HJT)*pi*app.BWJ;
%求解保温层外表面温度
x=vpasolve(app.BSR==app.GSR);
x=double(x);
%取实数的实数部
app.WBT=x(imag(x)==0);
APP封装时应该要把调用的内部函数都打包进去