1 内容介绍
COVID-19是由严重急性呼吸综合症冠状病毒2型引发的传染病,它最初病毒携带者是一些动物,传染源主要是COVID-19患者,无症状患者。传播方式主要是呼吸道飞沫近距离传播,接触传播,还有一些其他的传播方式待后续科研工作进一步证实。2019年12月,目前尚不知来源的新型冠状病毒COVID-19首先被报道于湖北省武汉市,随后由于寒假以及春运返潮等大规模人口流动,2020年1月底COVID-19蔓延扩散至全中国范围,使中国成为新型冠状病毒肺炎的重灾区;2020年3月底,COVID-19几乎肆虐地球上每一个国家,给全世界人民的生命安全和身体健康带来巨大威胁,给各国医护防控人员带来繁重的任务和巨大的压力,给世界经济带来严重阻力。因此,对COVID-19展开科学研究,探索它的传播机制,阻断它的传播渠道,能给COVID-19预防提供参考,控制提供数量依据,具有不可轻视的作用。
2 仿真代码
function importTotalCases
% write the results of parsing into the 'data' directory (MB 20/04/23)
oldFolder = cd('data');
pwd
% get the current date in YYYYMMDD format
currentDateYYYYMMDD = strrep(datestr(date, 26), '/', '');
% set the filenames
fileCSV = ['totalcases', currentDateYYYYMMDD, '.csv'];
fileXLSX = ['totalcases', currentDateYYYYMMDD, '.xlsx'];
% import data from <https://ourworldindata.org/coronavirus-source-data>
% download the 'totalcase.csv' file
tcFileCSV = websave(fileCSV,'https://covid.ourworldindata.org/data/ecdc/total_cases.csv');
% read the CSV file, and then save it to XLSX format
TMPFILE = readtable(fileCSV);
writetable(TMPFILE,fileXLSX);
% we will write the results of parsing into the appropriate folder;
% in order to use the original Milan Batista's code, we put:
path = pwd;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% STEP 2: Split the data for individual countries %%%
%%% Milan Batista's original code for parsing %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Amin = 5; % data les than Amin will be deleted from file begining
% get table
T = readtable(fileXLSX);
% get data
A = T{:,2:end};
[nrow,ncol] = size(A);
% table column names
name = string(T.Properties.VariableNames);
name = name(2:end)';
% start date
date0 = datenum(T{1,1}); %datenum(txt{2,1},'dd.mm.yyyy'); %datenum('2019/12/31');
% end date
%date1 = date0 + nrow - 1;
%functions names
ffname = strings(ncol,1);
nn = 0;
for n = 1:ncol
nname = name{n};
if strcmp("",nname)
continue
end
nn = nn + 1;
nname = strrep(nname,' ','_');
nname = strrep(nname,'-','_');
nname = strrep(nname,'''','_');
nname = strrep(nname,'(','_');
nname = strrep(nname,')','_');
fname = sprintf('getData%s.m',nname);
fid = fopen(fullfile(path,fname),'w');
if fid < 0
fprintf('***Fail to open %s\n',fname);
continue
end
fprintf('%d/%d country %s ...\n',ncol,n,nname);
ffname(nn) = nname;
fprintf(fid,'function [country,C,date0] = getData%s()\n',nname);
fprintf(fid,'%%GETDATA%s Coronavirus data for %s\n',upper(nname),nname);
fprintf(fid,'%% as reported by One World in Data\n');
fprintf(fid,'%% https://ourworldindata.org/coronavirus-source-data\n');
fprintf(fid,'country = ''%s'';\n',strrep(name(n),' ','_'));
fprintf(fid,'C = [\n');
found = false;
nday = 0;
for m = 1:nrow
if ~found && (isnan(A(m,n)) || A(m,n) == 0 || A(m,n) < Amin)
nday = nday + 1;
continue
else
found = true;
end
fprintf(fid,' %9d %% %s\n',A(m,n),datestr(date0 + m - 1));
end
fprintf(fid,'%%<-------------- add new data here\n');
fprintf(fid,']'';\n');
% start date
fprintf(fid,'date0=datenum(''%s'');\n',datestr(date0 + nday));
fprintf(fid,'end\n');
fclose(fid);
%generete driver rutine
fname = 'runAll.m';
fid = fopen(fullfile(path,fname),'w');
if fid < 0
fprintf('***Fail to open %s\n',fname);
continue
end
fprintf(fid,'prn = ''off'';\n');
fprintf(fid,'plt = ''on'';\n');
for n = 1:nn
fprintf(fid,'try\n');
fprintf(fid,' fitVirusCV19(@getData%s,''prn'',prn,''jpg'',plt)\n',...
ffname(n));
fprintf(fid,'end\n');
end
fclose(fid);
cd(oldFolder)
end
3 运行结果
4 参考文献
[1]任中贵. 基于SIR模型的COVID-19疫情数据分析[J]. 电子元器件与信息技术, 2020, 4(7):3.
[2]成红胜, 成诚. 基于COVID-19传染病SIR模型的稳定性分析[J]. 淮阴师范学院学报:自然科学版, 2021, 20(4):6.