如何在Matlab中创建表?

时间:2016-09-01 09:57:34

标签: matlab

以下是我用来计算PMV点数的图表: A,B,C,D,E Graphic

%This is the code I used to calculate the PMV at points: A, B, C, D, E.
%Where:
%ta=tr=interior temperature setting (22°C, 23°C, 27°C) (variable);
%va=0,2 m/s (invariable);
%RH=50% (invariable);
%W=0 (invariable);
%Met= energy metabolism (1,2 met or 1,4 met) (variable);
%Iclo= static clothing insulation (0,5 clo or 1,0 clo) (variable).

ta=22.0;
tr=22.0;
va=0.2; %air speed
RH=50; %relative humidity
W=0;%mechanical work
Met=1.2;%energy metabolism in met (1 met=58.2 W/m2)
Iclo=0.5;%static clothing insulation
%preparation of variables
PHI=RH/100;%hygrometric dimensionless degree 
Icl=Iclo*.155;%Conversion from clo to m2K/W 
M=Met*58.15;%conversion of metabolism in unit of measurement of SI
Iclr=Icldyn_7730(va, Icl, M); %calculation of dynamic clothing insulation
vw=0.0052*(M-58);
vr=va+vw;
PMV_Fanger=PMV_evaluator( M,W,ta,tr,vr,PHI,Iclr );

观察:我调用的函数如下:“Icldyn_7730”

function [ Icldyn ] = Icldyn_7730(va, Iclst, M)
%calculation of dynamic clothing insulation
%Input data
% va, air speed, m/s
% Iclst, static clothing insulation
% M, metabolism in W/m2
vw=0.0052*(M-58);
if vw>0.7
    vw=0.7;
end
vr=va+vw;
%Static cloting insulation conversion m2K/W to clo
   Iclo =  Iclst/0.155;

%Clothing area factor
   if Iclst <=0.078 
   fcl= 1.00 + 1.290 * Iclst;
   else
   fcl= 1.05 + 0.645 * Iclst;
   end
%Static boundary layer thermal insulation in quiet air in m2K/W
   Iast =  0.111;

%Total static insulation
   Itotst= Iclst + Iast / fcl;

%Clothing insulation correction for wind (vr) and and walking (vw)
   vraux= vr;
   if vraux > 3.5 
       vraux=3.5;
   end

   if vraux < 0.15 
       vraux=0.15;
   end

   vwaux=vw;
   if vwaux>0.7
       vwaux=0.7;
   end

   CorIt=exp(-0.281*(vraux-0.15)+0.044*(vraux-0.15)^2-0.492*vwaux+0.176*vwaux^2);
   if CorIt>1 
   CorIt=1;
   end

   CorIa=exp(-0.533*(vraux-0.15)+0.069*(vraux-0.15)^2-0.462*vwaux+0.201*vwaux^2);
   if CorIa>1 
   CorIa=1;
   end

   Itr = Itotst * CorIt;
   Iar = CorIa * Iast;
   if Iclo<=0.6 
       Itr= ((0.6-Iclo) * Iar + Iclo * Itr) / 0.6;
   end

   Itdyn = Itr;
   Iadyn = Iar;
   Icldyn = Itdyn - Iadyn / fcl;
end

和“PMV_evaluator”

function [ PMV ] = PMV_evaluator( M,W,ta,tr,vr,PHI,Icl )
%Function for the calculation of the PMV index
%   Input data
%   M, metabolic rate in W/m2
%   W, mechanical work in W/m2
%   ta, air temperature in °C
%   tr, mean radiant temperature in °C
%   vr, rwlative air velocity in m/s
%   PHI, hygrometric ratio dimensionless
%   Icl in m2K/W (dynamic clothing insulation )
if (ta >=0)
ps   =   exp (16.6536-4030.183 / (235 + ta ));
else
    ps   =   0.6105* exp (21.875*ta / (265.5 + ta ));
end;

TAA  =  ta+273.0;
TRA  =  tr+273.0;
TCLA =  TAA + (35.5-ta) / (3.5*Icl+0.1);
hcf = 12.1 * sqrt(vr);

%Clothing area factor
if Icl <=0.078 
fcl= 1.00 + 1.290 * Icl;
else
fcl= 1.05 + 0.645 * Icl;
end
% Start of the loop for the evaluation of clothing surface temperature}
P1   = Icl * fcl;
P2   = P1 * 3.96;
P3   = P1 * 100;
P4   = P1 * TAA;
P5   = 308.7 - 0.028 * (M-W) + P2 * (TRA/100)^4;
XN   = TCLA/100;
XF   = XN;
EPS  = 0.00015;
CONV = 100;
N=1;
while (CONV>EPS) 
XF   = (XF+XN)/2;
hcn = 2.38 * ((abs(100*XF - TAA))).^0.25;
if (hcf<=hcn) 
hc   = hcn;
else
hc   = hcf;
end
XN   = (P5+P4*hc-P2*XF^4)/(100+P3*hc);
CONV=abs(XF-XN);
end

tcl  = 100*XN-273;
% End of the loop for the evaluation of clothing surface temperature}

%Skin diffusion heat loss
HL1=3.05*0.001*(5733-6.99*(M-W)-1000*PHI*ps);

%Sweat heat loss
if (M-W)>58.15 
    HL2= 0.42 * ((M-W)-58.15);
else
    HL2=0;
end

%Respiration latent heat loss
HL3= 1.7*0.00001 * M * (5867-1000*PHI*ps);

%Respiration dry heat loss
HL4= 0.0014 * M * (34-ta);

%Radiative heat loss
HL5= 3.96 * fcl * ((0.01*tcl+2.73)^4-(0.01*tr+2.73)^4);

%Convective heat loss
HL6= fcl * hc * (tcl-ta);

%Thermal sensation transformation coefficient}
TS= 0.303 * exp(-0.036*M) + 0.028;

PMV= TS * (M-W-HL1-HL2-HL3-HL4-HL5-HL6);
end

如何使用MATLAB创建如下表格?

table

表中的数据是PMV的值。它们是从MATLAB的个别计算中获得的。

2 个答案:

答案 0 :(得分:0)

考虑使用matlab更高版本中引入的表变量,此变量允许不同的数据源。完整的matlab帮助有example,其中一组分类行名称占据第一列,而一组标题占据顶部。

matlab中的可写命令也会将表变量(行/列/标题等)写入excel电子表格。

答案 1 :(得分:0)

表达zhqiat的回答,您的表可以通过以下代码生成:

data = [-1.5924 -0.2152 -1.1426 0.0421; -1.5924 -0.2152 -1.1426 0.0421; -1.2319 0.0313 -0.8241 0.2595; 0.2329 1.0332 0.4686 1.1427; 0.2329 1.0332 0.4686 1.1427];
row_names = {'A', 'B', 'C', 'D', 'E'};
var_names = {'met1d2_clo0d5', 'met1d2_clo1d0', 'met1d4_clo0d5', 'met1d4_clo1d0'};
var_description = {'M = 1.2 met - 0.5 clo', 'M = 1.2 met - 1. clo', 'M = 1.4 met - 0.5 clo', 'M = 1.4 met - 1.0 clo' };
testtable = array2table(data, 'VariableNames', var_names, 'RowNames', row_names);
testtable.Properties.VariableDescriptions = var_description;

这将导致如下所示: Screenshot of Matlab-Table

我们大家可能都会误解您的问题。因此,如果缺少正确的答案,请尝试对其进行完善。