필터 지우기
필터 지우기

Pie Chart Help please

조회 수: 9 (최근 30일)
Cizzxr
Cizzxr 2021년 2월 11일
답변: Deepak Meena 2021년 2월 26일
Hi, im having trouble with my code when perfoming a pie chart. I have an excel file named 'Full_cube_data'
that is a 108x3 matrix. The third column is the gender column filled full of 1's and 0's with 1 representing a male and a
female 0. This is the code i have currently to import the data, to create a matrix from the data and then to count how many
1's or 0's there are. But im really not sure how im meant to use the 'malecount and 'femalecount' to create the pie chart.
Full_cube_data = importdata('Full_Cube_data.xlsx');
gender = Full_cube_data.textdata(:,3);
gender = cell2mat(gender);
maleCount = size(find(gender == '1'),1);
femaleCount = size(find(gender == '0'),1);
grr = [femaleCount maleCount];
pie(grr)

답변 (1개)

Deepak Meena
Deepak Meena 2021년 2월 26일
Hi Ciaram,
Refer to the pie chart documentation.I think you want to do something like this :
malecount = 45;
femalecount = 62;
grr = [malecount femalecount];
labels = {'male', 'female'};
pie(grr,labels);

카테고리

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