LoginSignup
3
0

More than 3 years have passed since last update.

matlab でCSSEGISandData/COVID-19のデータの取り出し方を自習してみた

Last updated at Posted at 2020-03-14

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')

3月14日のグラフ

corvit.png

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0