One way to create a list that returns all male names in matlab is by using logical indexing with the gender variable. Here's how to do it:
main.m259 chars9 lines
The variable is_male is a logical index of the same length as gender, with 1 where the corresponding gender is 'male' and 0 where it is not. We can use this logical index to select the male names from the names variable using square brackets with logical indexing. The result is a list of all male names: 'chris' and 'juan':
main.m58 chars6 lines
gistlibby LogSnag