How can I make a categorical variable based on a simple rule for a numeric variable?

Unfortunately all my searching hasn't led me this very simple problem.
I want to make a new binary variable "y" that is 0 for values of "yraw" that are <12, and "1" for values that are >12.
How can I do this?

 Respuesta aceptada

You don't define how the rule works when y == 12. I made a choice for you.
y = double(yraw >= 12);
You don't really need to use double there, but depending on what you will do with the variable y, some operations will require that y be a double precision variable.
However, I think you really need to just start reading the basic getting started tutorials.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Dic. de 2017

Respondida:

el 16 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by