Compare values and change them
1 次查看(过去 30 天)
显示 更早的评论
Lets say i have matrix A=[1 2 3;4 2 7;9 6 1] I want the values less than 5 to be replaced with zero, and bigger than 5 to be replaced with 1 in this case should be this answer A=[0 0 0;0 0 1;1 1 0] Hope someone will assist me...thanks.
0 个评论
采纳的回答
Azzi Abdelmalek
2014-6-13
编辑:Azzi Abdelmalek
2014-6-13
A(A<5)=0
A(A>5)=1
You have to consider when the value is equal to 5
You can also have the result by
A=[1 2 3;4 2 7;9 6 1]
B=A>5
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!