path='D:\Desktop\abc\';
Files = dir(strcat(path,'*.xlsx'));
LengthFiles = length(Files);%%将每次循环不同的文件都输出结果
for i = 1:LengthFiles
    xls_data = xlsread(strcat(path,Files(i).name));
    file_name=Files(i).name;
    nosch_male_sum = sum(xls_data(:,2));%文盲
    nosch_male_per = xls_data(:,2)/nosch_male_sum;
    nosch_female_sum = sum(xls_data(:,3));
    nosch_female_per = xls_data(:,3)/nosch_female_sum;
    primary_male_sum=sum(xls_data(:,4));%小学
    primary_male_per = xls_data(:,4)/primary_male_sum;
    primary_female_sum = sum(xls_data(:,5));
    primary_female_per = xls_data(:,5)/primary_female_sum;
    junior_male_sum=sum(xls_data(:,6));%初中
    junior_male_per = xls_data(:,6)/junior_male_sum;
    junior_female_sum = sum(xls_data(:,7));
    junior_female_per = xls_data(:,7)/junior_female_sum;
    senior_male_sum = sum(xls_data(:,8));%高中
    senior_male_per = xls_data(:,8)/senior_male_sum;
    senior_female_sum = sum(xls_data(:,9));
    senior_female_per = xls_data(:,9)/senior_female_sum;
    college_male_sum = sum(xls_data(:,10));%大专
    college_male_per = xls_data(:,10)/college_male_sum;
    college_female_sum = sum(xls_data(:,11));
    college_female_per = xls_data(:,11)/college_female_sum;
    university_male_sum = sum(xls_data(:,12));%本科
    university_male_per = xls_data(:,12)/university_male_sum;
    university_female_sum = sum(xls_data(:,13));
    university_female_per = xls_data(:,13)/university_female_sum;
    edu_male = primary_male_per.*0.2024+junior_male_per.*0.2673+senior_male_per.*0.3007+college_male_per.*0.3526+university_male_per.*0.3805;%男性edu1987年方程
    edu_female = primary_female_per.*0.2024+junior_female_per.*0.2673+senior_female_per.*0.3007+college_female_per.*0.3526+university_female_per.*0.3805;%女性edu1987年方程
    male = xls_data(:,4)  + xls_data(:,6) + xls_data(:,8) + xls_data(:,10) + xls_data(:,12);%男性总人口
    female = xls_data(:,5)  + xls_data(:,7) + xls_data(:,9) + xls_data(:,11) + xls_data(:,13);%女性总人口
    HC_edu_male = edu_male .* male;%人口加权的男性教育方面人力资本
    HC_edu_female = edu_female .* female;%人口加权的女性教育方面人力资本
    HC_edu_totmale = sum(HC_edu_male(16:60));%男性总教育人力资本
    HC_edu_totfemale = sum(HC_edu_female(16:60));%女性总教育人力资本
    pop = sum( xls_data(:,2:13),2);%分年龄段总人口
    totpop = sum(pop(16:60,:),1);%总人口（大于14岁的）
    HC_exp_primary = (xls_data(:,14).* xls_data(:,4)) + (xls_data(:,15).* xls_data(:,5));%分年龄小学经验人力资本
    HC_exp_junior = (xls_data(:,16).* xls_data(:,6)) + (xls_data(:,17).* xls_data(:,7));
    HC_exp_senior = (xls_data(:,18).* xls_data(:,8)) + (xls_data(:,19).* xls_data(:,9));
    HC_exp_college = (xls_data(:,20).* xls_data(:,10)) + (xls_data(:,21).* xls_data(:,11));
    HC_exp_university = (xls_data(:,22).* xls_data(:,12)) + (xls_data(:,23).* xls_data(:,13));
    HC_exp_totprimary = sum(HC_exp_primary(16:60));%总的小学经验人力资本
    HC_exp_totjunior = sum(HC_exp_junior(16:60));
    HC_exp_totsenior = sum(HC_exp_senior(16:60));
    HC_exp_totcollege = sum(HC_exp_college(16:60));
    HC_exp_totuniversity = sum(HC_exp_university(16:60));
    HC_edu=HC_edu_totmale+HC_edu_totfemale;%总的教育的人力资本
    HC_edu_aver=HC_edu/totpop;%教育的人均人力资本
    HC_exp=HC_exp_totprimary+HC_exp_totjunior+HC_exp_totsenior+HC_exp_totcollege+HC_exp_totuniversity;%总的经验的人力资本
    HC_exp_aver=HC_exp/totpop;%经验的人均人力资本
    HC=HC_edu+HC_exp;%总的人力资本
    HC_aver=HC/totpop;%总的人均人力资本
end