Evaluating Excel Data to organize data

1 次查看(过去 30 天)
I am trying to evaluate the Excel file but am unsure of how to get the values for the criteria below... I know how to import the Excel file but not sure if I need to make it a cell or table. I have never plotted a pie chart in MatlabAny help is appreciated!
-The name of the 20th runner.
-The home town and state of the last runner.
-The age of the first runner (winner).
-The first letter in the 5th runner's name.
-Count the number of males and females in the race.
-Display the age of youngest runner
-Display the age of oldest runner
-Create a pie chart that shows the percentage of male and female runners.

回答(1 个)

Navya Seelam
Navya Seelam 2019-12-6
Hi,
You can use importdata to load file into workspace which gives you a structure with fields data and textdata. You can use cell2mat to convert cell array to string array.
T= importdata('marathon.xlsx');
gender=T.textdata(:,4);
gender=cell2mat(gender);% to convert cell array to string array
maleCount=size(find(gender=='M'),1);
femaleCount=size(find(gender=='F'),1);
Once you have male and female count you can easily create pie chart. Refer to this link to create pie chart.

Community Treasure Hunt

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

Start Hunting!

Translated by