find data with same name

조회 수: 1 (최근 30일)
John fredson
John fredson 2022년 5월 20일
댓글: KSSV 2022년 5월 20일
For this two data file, I need to plot population of each country in population file with correspond death in owid data file , but they are difference in size, how can I do it?
  댓글 수: 2
John fredson
John fredson 2022년 5월 20일
am using readtable function
Ilya Dikariev
Ilya Dikariev 2022년 5월 20일
You don't need Matlab to do it, it is much easier with excel itself. However, if you want to do it in matlab so strongly then small hint: you can use unique and sum, and extract that column. Or first create new table with filter+pivot table in excel so you can get the total number of death per country and use it in Matlab plot

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2022년 5월 20일
You can get the deaths of each country using:
T1 = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1005245/owid-covid-data_2020-21.csv') ;
T2 = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1005250/Population_data.xlsx') ;
[m,n] = size(T2) ;
C = T2.Location ; % countries
P = T2.Population_million_ ; % population
D = zeros(m,1) ; % deaths in each country
for i = 1:m
idx = strcmp(T1.Location,T2.Location{i}) ;
D(i) = sum(T1{idx,7}) ;
end
Now you can plot what you want.
  댓글 수: 2
John fredson
John fredson 2022년 5월 20일
how to make the population not in 10^6 form?
KSSV
KSSV 2022년 5월 20일
REad about format

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by