Evaluating Excel Data to organize data

조회 수: 3 (최근 30일)
Lauren Kilgore
Lauren Kilgore 2019년 12월 3일
답변: Navya Seelam 2019년 12월 6일
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.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by