CSSEGISandData/COVID-19 データ
matlab でのデータの読み込みの練習がてら、GitHub にあったので、time_series を読み込んでみた。テーブルをアレイにしたり、数字についたシングルクォーテーションの取り扱いを少し学べたと思う。
coviddata.m
clear
confirmed=readtable('csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv');
deaths=readtable('csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv');
recovered=readtable('csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv');
c=table2array(confirmed);
d=table2array(deaths);
r=table2array(recovered);
countries = {'Japan','Cruise Ship','Italy','Iran','Hubei'}
n=size(c,2);
figure(1);clf
for a = 1:5
[i j]=find(string(c)==countries{a}); % this is also ok---%[i j]=find(strcmp(c,'Japan'));
cc=c(i,5:n);
dd=d(i,5:n);
rr=r(i,5:n);
for k = 1:n-4
ccc(k)=str2num(cell2mat(cc(k)))
ddd(k)=str2num(cell2mat(dd(k)))
rrr(k)=str2num(cell2mat(rr(k)))
end
ptnum=ccc-ddd-rrr;
subplot(2,3,a)
plot(ccc,'b');
hold on
plot(ddd,'r')
plot(rrr,'g')
plot(ptnum,'c')
title(countries{a})
xticklabels(c(1,5:10:n))
end
legend('confirmed','deaths','recovered','current patients')