Converting 1 and 2 to False and True

89 visualizaciones (últimos 30 días)
Antonio Lorenzo Sahagun
Antonio Lorenzo Sahagun el 8 de Sept. de 2021
Respondida: Jan el 8 de Sept. de 2021
Hello!
I've been working on a prediction model where the output is supoosed to be TRUE or FALSE. However the way my model outputs the results is in 1 and 2. Whats the most efficient way to convert the 1 and 2s in the column to TRUE or FALSE. Thanks in advance!

Respuesta aceptada

Image Analyst
Image Analyst el 8 de Sept. de 2021
If it returns result as a double or an integer, you can do
tf = logical(2 - result);
  2 comentarios
Antonio Lorenzo Sahagun
Antonio Lorenzo Sahagun el 8 de Sept. de 2021
how to make it come out as 'TRUE' or 'FALSE'
Image Analyst
Image Analyst el 8 de Sept. de 2021
Editada: Image Analyst el 8 de Sept. de 2021
If you want a character array instead of a logical/boolean variable, you can use an if statement
if result == 1
tf = 'TRUE'; % Or "TRUE" if you want a string type variable.
else
tf = 'FALSE'; % Or "FALSE" if you want a string type variable.
end
Is that what you want?

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 8 de Sept. de 2021
result = [1; 2; 1; 1; 2];
Pool = {'FALSE', 'TRUE'};
Pool((result == 1) + 1)
ans = 1×5 cell array
{'TRUE'} {'FALSE'} {'TRUE'} {'TRUE'} {'FALSE'}

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by