数学建模省赛小结:数据预处理(按照关键字提取行/列并进行简单运算)
function []=datapro714()% 处理的数据截止7/14/20
% [csvdata,~,rawcsvdata] = xlsread('who_covid_19_sit_rep_time_series.csv');
[~,~,rawconfirmed] = xlsread('time_series_covid_19_confirmed.csv');
[~,~,rawDeaths] = xlsread('time_series_covid_19_Deaths.csv');
[~,~,rawRevored] = xlsread('time_series_covid_19_Recovered.csv');
% [csvdata,~,rawcsvdata] = xlsread('who_covid_19_sit_rep_time_series.csv');
[~,~,rawconfirmed] = xlsread('time_series_covid_19_confirmed.csv');
[~,~,rawDeaths] = xlsread('time_series_covid_19_Deaths.csv');
[~,~,rawRevored] = xlsread('time_series_covid_19_Recovered.csv');
[China_C,USA_C,Italy_C,France_C,Australia_C,Korea_C,India_C ]= getdata(rawconfirmed,1);
[China_D,USA_D,Italy_D,France_D,Australia_D,Korea_D,India_D ]= getdata(rawDeaths,1);
[China_Re,USA_Re,Italy_Re,France_Re,Australia_Re,Korea_Re,India_Re ]= getdata(rawRevored,2);
China_I714=China_C-(China_D+China_Re);
USA_I714=USA_C-(USA_D+USA_Re);
Italy_I714=Italy_C-(Italy_D+Italy_Re);
France_I714=France_C-(France_D+France_Re);
Australia_I714=Australia_C-(Australia_D+Australia_Re);
Korea_I714=Korea_C-(Korea_D+Korea_Re);
India_I714=India_C-(India_D+India_Re);
[China_D,USA_D,Italy_D,France_D,Australia_D,Korea_D,India_D ]= getdata(rawDeaths,1);
[China_Re,USA_Re,Italy_Re,France_Re,Australia_Re,Korea_Re,India_Re ]= getdata(rawRevored,2);
China_I714=China_C-(China_D+China_Re);
USA_I714=USA_C-(USA_D+USA_Re);
Italy_I714=Italy_C-(Italy_D+Italy_Re);
France_I714=France_C-(France_D+France_Re);
Australia_I714=Australia_C-(Australia_D+Australia_Re);
Korea_I714=Korea_C-(Korea_D+Korea_Re);
India_I714=India_C-(India_D+India_Re);
fig1=figure
plot(date,China_I714,'k',date,China_D+China_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('中国疫情曲线图')
fig2=figure
plot(date,USA_I714,'k',date,USA_D+USA_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('美国疫情曲线图')
fig3=figure
plot(date,Italy_I714,'k',date,Italy_D+Italy_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('意大利疫情曲线图')
fig4=figure
plot(date,France_I714,'k',date,France_D+France_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('法国疫情曲线图')
fig5=figure
plot(date,Australia_I714,'k',date,Australia_D+Australia_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('澳大利亚疫情曲线图')
fig6=figure
plot(date,Korea_I714,'k',date,Korea_D+Korea_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('韩国疫情曲线图')
fig7=figure
plot(date,India_I714,'k',date,India_D+India_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('印度疫情曲线图')
plot(date,China_I714,'k',date,China_D+China_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('中国疫情曲线图')
fig2=figure
plot(date,USA_I714,'k',date,USA_D+USA_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('美国疫情曲线图')
fig3=figure
plot(date,Italy_I714,'k',date,Italy_D+Italy_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('意大利疫情曲线图')
fig4=figure
plot(date,France_I714,'k',date,France_D+France_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('法国疫情曲线图')
fig5=figure
plot(date,Australia_I714,'k',date,Australia_D+Australia_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('澳大利亚疫情曲线图')
fig6=figure
plot(date,Korea_I714,'k',date,Korea_D+Korea_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('韩国疫情曲线图')
fig7=figure
plot(date,India_I714,'k',date,India_D+India_Re,'b');grid on
legend('感染者曲线','移出者曲线(死亡+治愈)');
title('印度疫情曲线图')
date=(1:size(China_C,2));
plot(date,China_C,'r',date,USA_C,'m',date,Italy_C,'b',date,France_C,'k',date,Australia_C,'c',date,Korea_C,'k--',date,India_C,'g');grid on
legend('中国','美国','意大利','法国','澳大利亚','韩国','印度')
title('各个国家累计确诊病例曲线图')
plot(date,China_C,'r',date,USA_C,'m',date,Italy_C,'b',date,France_C,'k',date,Australia_C,'c',date,Korea_C,'k--',date,India_C,'g');grid on
legend('中国','美国','意大利','法国','澳大利亚','韩国','印度')
title('各个国家累计确诊病例曲线图')
end
function [China_RR,USA_RR,Italy_RR,France_RR,Australia_RR,Korea_RR,India_RR ]= getdata(rawcsvdata,Flag) for i=1:length(rawcsvdata) % if strcmp(rawcsvdata{i,2},'China')==1 %33+Taiwan % count_China=i; % count_China=count_China+1; if strcmp(rawcsvdata{i,2},'China')==1 %33+Taiwan count_China_start=i-32; count_China_end=i; China_33=rawcsvdata(count_China_start:count_China_end,:); %提取出33个省的数据; elseif strcmp(rawcsvdata{i,2},'Taiwan*')==1 %提取出台湾的数据 taiwan=rawcsvdata(i,:); % elseif strcmp(rawcsvdata{i,2},'United States of America')==1 % %time_series_covid_19_confirmed.csv 文件中是 'United States of America' elseif strcmp(rawcsvdata{i,2},'US')==1 %time_series_covid_19_confirmed.csv 文件中是'US' USA_R=rawcsvdata(i,:); elseif strcmp(rawcsvdata{i,2},'Italy')==1 Italy_R=rawcsvdata(i,:); % elseif strcmp(rawcsvdata{i,2},'France')==1 % row 118 % France_R=rawcsvdata(i,:); elseif strcmp(rawcsvdata{i,2},'Australia')==1 %澳洲=澳洲部分地区相加 count_Aus_start=i-7; count_Aus_end=i; Australia_8=rawcsvdata(count_Aus_start:count_Aus_end,:); %提取出8个省的数据; elseif strcmp(rawcsvdata{i,2},'Korea, South')==1 %找不到韩国的 Korea_R=rawcsvdata(i,:); %% elseif strcmp(rawcsvdata{i,2},'India')==1 India_R=rawcsvdata(i,:); % elseif (strcmp(rawcsvdata{i,2},'China')==1)&&(strcmp(rawcsvdata{i,1},'Deaths')==1) % China_Deaths=rawcsvdata(i,:); end if Flag==1 France_R=rawcsvdata(118,:); elseif Flag==2 France_R=rawcsvdata(110,:); end end China_34R=[China_33;taiwan]; China_34RR=cell2mat(China_34R(:,5:end)); China_RR=sum(China_34RR,1); %34个省求和(按列) USA_RR=cell2mat(USA_R(:,5:end)); Italy_RR=cell2mat(Italy_R(:,5: end)); France_RR=cell2mat(France_R(:,5:end)); Australia_8R=cell2mat(Australia_8(:,5:end)); Australia_RR=sum(Australia_8R,1); Korea_RR=cell2mat(Korea_R(:,5:end)); India_RR=cell2mat(India_R(:,5:end)); end
所需数据文件:https://files.cnblogs.com/files/feynmania/data.rar