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

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 日

0 投票

b = a;
b(b==1) = 0;

3 件のコメント

mary
mary 2013 年 12 月 4 日
perfect thanx alot
José-Luis
José-Luis 2013 年 12 月 4 日
Please accept an answer if it helped you.
mary
mary 2013 年 12 月 7 日
sure i just forgot ,, sorry ,, thanx again

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2013 年 12 月 4 日

コメント済み:

2013 年 12 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by