How to draw a graph from this table

조회 수: 6 (최근 30일)
alpedhuez
alpedhuez 2021년 4월 1일
편집: Shubham Khatri 2021년 4월 9일
I have a spreadsheet of the format
2021 2020 2019
male 50 45 40
female 50 55 60
I now want to draw a graph with x axis years and y axis male and female. I also want to draw a pie chart of 2021 for male and female.

채택된 답변

Shubham Khatri
Shubham Khatri 2021년 4월 9일
편집: Shubham Khatri 2021년 4월 9일
Hello,
You can start by reading data from excel by using readtable. You can find more information about readtable here.
To draw the graph, you can use the plot function. To draw a pie chart you can use the function pie. I am providing a sample code here to help you
gender=[50 45 40; 50 55 60] %The table which I got from the excel
plot(gender(1,:),gender(2,:)) %using plot function, the first row is for male and the second for females
pie(gender(:,1)) % plotting a pie chart for all rows and with the first column( year 2021)
Hope it helps

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by