Extract Data From Imported Excel Sheet Containing Specific Numeric Values
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
dpb
2021-2-1
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!