Converting 1 and 2 to False and True
91 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
Image Analyst
2021-9-8
If it returns result as a double or an integer, you can do
tf = logical(2 - result);
2 个评论
Image Analyst
2021-9-8
编辑:Image Analyst
2021-9-8
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?
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!