function tradebariers = tb(NEX,NIM,NIN,EL_CP)
[m,n]=size(NEX);
tradebariers = zeros(m,n);
for i=1:1:31
    A1 = NEX(1+(i-1)*31:i*31,:);     
    B1 = NIM(1+(i-1)*31:i*31,:);    
    C1 = NIN(i,:);                   
    C2 = C1.*NIN;                    
    C3 = A1.*B1;                     
    C4 = C2./C3;                     
    tradebariers(1+(i-1)*31:i*31,:)=real(C4.^EL_CP);   %计算贸易壁垒 （其中第31行为国际贸易壁垒） 
end
% check：当区域间贸易额为0时，计算得到的贸易壁垒趋向于无穷大，这里将其取1；加权贸易壁垒是，权重为0，并不影响结果
tradebariers(isinf(tradebariers))=0;
tradebariers(isnan(tradebariers))=0;
tradebariers(:,13)=0;
end