Filter rows based on presence of string

2 visualizaciones (últimos 30 días)
Anaya Kharwadkar
Anaya Kharwadkar el 8 de Nov. de 2020
Respondida: madhan ravi el 8 de Nov. de 2020
I have a 100 x 1 vector called 'gender'. There are only two values in the vector: 'male' and 'female'. These are string values. I want to convert 'gender' to a binary variable with 'male' as '1' and female as '0'.
How do I go about this?
Any help would be appreciated.

Respuestas (2)

Star Strider
Star Strider el 8 de Nov. de 2020
If you have R2015b or later use the findgroups function. Otherwise, use the third output of the unique function to do the same thing.

madhan ravi
madhan ravi el 8 de Nov. de 2020
Wanted = ismember(vector, 'male')

Categorías

Más información sobre Argument Definitions 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!

Translated by