필터 지우기
필터 지우기

Plotting a line graph

조회 수: 6 (최근 30일)
Abdullah KHAN
Abdullah KHAN 2020년 11월 8일
답변: Rupesh Revankar 2022년 8월 3일
I'm completly new to Matlab and am trying to plot COVID-19 case numbers by country. On the y-axis I want the date, and on the x-axis I want the amount of covid-19 cases. (with lines for different countries)
I've created a datastore, then a tall array from where I have used the gather function to select certain rows of data. I'm not sure how to create a line graph from the table.
  • I know how to label x-axis and y-axis and the title.

채택된 답변

Abhisek Pradhan
Abhisek Pradhan 2020년 11월 10일
The following link may help you plot the data as it is quite straight forward. Trying taking an example which suits your requirement.

추가 답변 (2개)

Peter Perkins
Peter Perkins 2020년 11월 19일
The simple answer for one country is just (ignoring the fact that most people would want time along the horizontal axis)
plot(s.Australia,s.Date)
If you want multiple countries, you could loop over the table's count vars and plot using hold on, but this should also work
plot(s{:,2:end},s.Date)
The braces allow you to extract multiple variables (as long as they are the same type), and plot will make separate lines for each column of the double matrix that s{:,2:end} creates. You'll want to add a legend with the country names.

Rupesh Revankar
Rupesh Revankar 2022년 8월 3일
mat karo

카테고리

Help CenterFile Exchange에서 Epidemiology에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by