Extract Data From Imported Excel Sheet Containing Specific Numeric Values
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
James Metz
el 31 de En. de 2021
Respondida: dpb
el 1 de Feb. de 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
...
0 comentarios
Respuesta aceptada
dpb
el 1 de Feb. de 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>
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!