2021年全球国家人口数据分析 - MATLAB代码实现
% 读取数据文件\n data = readtable('population.csv');\n\n % 提取国家和2021年的总人口数据\n country = data.Country;\n population2021 = data.Population2021;\n\n % 根据总人口数降序排序\n [~, idx] = sort(population2021, 'descend');\n sorted_country = country(idx);\n sorted_population2021 = population2021(idx);\n\n % 绘制柱状图\n figure\n bar(sorted_population2021(1:10))\n title('2021年不同国家总人口数')\n xlabel('国家')\n ylabel('总人口数')\n xticklabels(sorted_country(1:10))\n xtickangle(45)\n\n % 输出总人口最多的前10个国家和最少的后10个国家名单\n disp('总人口最多的前10个国家:')\n disp(sorted_country(1:10))\n\n disp('总人口最少的后10个国家:')\n disp(sorted_country(end-9:end))
原文地址: https://www.cveoy.top/t/topic/pJVA 著作权归作者所有。请勿转载和采集!