function [Cos_dtb,In_dtb,Cos_ftb,In_ftb] = merge_region(export,import,DTB,FTB)
% 单个年份分析
% 将贸易区分为国内贸易和国际贸易
[export_d,export_f]=classfy(export); % 省际调出900*17和出口30*17
[import_d,import_f]=classfy(import); % 省际调入900*17和进口30*17

% 沿海地区和内陆地区国内贸易壁垒加权
SJTRADE = export_d+import_d; % 900*17
for i=1:1:30
    SJTRADE(31*i-30,:)=0;  % 剔除各省内部贸易
end
SJTRADE_Pro_0 = sum(SJTRADE,2); %两省之间贸易加总
SJTRADE_Pro_1 =zeros(30,1);
for i=1:1:30
    NONE = SJTRADE_Pro_0(1+(i-1)*30,:);
    SJTRADE_Pro_1(i,:)= sum(NONE); % 各省双边贸易
end
[coa_dtrade,inl_dtrade]=Reg_Di(SJTRADE_Pro_1);
[coa_dtb,inl_dtb]=Reg_Di(DTB);
weight_dcoa = coa_dtrade./sum(coa_dtrade);  % 沿海各省份国内贸易权重
weight_dinl = inl_dtrade./sum(inl_dtrade);  % 内陆各省份国内贸易权重

Cos_dtb_0 = coa_dtb.*weight_dcoa;
Cos_dtb = sum(Cos_dtb_0);

Inl_dtb_0 = inl_dtb.*weight_dinl;
In_dtb = sum(Inl_dtb_0);

% 沿海地区和内陆地区国际贸易壁垒加权
GTTRADE = export_f+import_f; %
GTTRADE_Pro = sum(GTTRADE,2);
[coa_ftrade,inl_ftrade]=Reg_Di(GTTRADE_Pro);
[coa_ftb,inl_ftb]=Reg_Di(FTB);
weight_fcoa = coa_ftrade./sum(coa_ftrade);  % 沿海各省份国内贸易权重
weight_finl = inl_ftrade./sum(inl_ftrade);  % 内陆各省份国内贸易权重

Cos_ftb_0 = coa_ftb.*weight_fcoa;
Cos_ftb = sum(Cos_ftb_0);

Inl_ftb_0 = inl_ftb.*weight_finl;
In_ftb = sum(Inl_ftb_0);

end