Extract Data From Imported Excel Sheet Containing Specific Numeric Values

5 vues (au cours des 30 derniers jours)
James Metz
James Metz le 31 Jan 2021
Réponse apportée : dpb le 1 Fév 2021
Hi all. I have imported a large 655x6 data set from excel onto MATLAB and am now trying to extract certain data from the table. The data has a column titled "gender" where male is denoted by a 1 and female by a 0. I want to create two separate arrays: one with all the females, and one with all the males. The arrays need to also contain all additional information in the row associated with each male or female (i.e. their height, ID, FEV, etc.). I sifted through the MathWorks help page about data sets, but I am not too good with syntax. Can anyone help?
This is how the spreadsheet is set up:
ID Height FEV Gender Smoker etc......
1 123 70 63 0 1
2 456 63 102 1 0
3
4
...

Réponse acceptée

dpb
dpb le 1 Fév 2021
Rather than duplicating the same data in multiple places, use grouping variables to process the data by the desired categories/groups. See https://www.mathworks.com/help/matlab/ref/splitapply.html for a very similar type of dataset example.
NB that if you use the table instead of an array you get the benefit if handling disparate data types together (where in your data Gender, Smoker are prime categorical variables), you can do this with rowfun.
I just pointed another Q? in the same direction <here>

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by