if i want to change each value 1 in a matrix to 0 how to do that?

1 次查看(过去 30 天)
a=[1 2 3;1 3 3;2 1 2]
is there a function that make a as below
b=[0 2 3;0 3 3;2 0 2]
  2 个评论
José-Luis
José-Luis 2013-12-4
Is this homework?
This can be solved with a combination of loops (for) and conditional statements (if), or in a syntactically simpler way with logical indexing.
mary
mary 2013-12-4
nop i just want a function some reduced thing instead of using loops

请先登录,再进行评论。

采纳的回答

José-Luis
José-Luis 2013-12-4
b = a;
b(b==1) = 0;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by