how can i assign the same values in an array with 1?

2 ビュー (過去 30 日間)
suchismita
suchismita 2016 年 2 月 6 日
コメント済み: suchismita 2016 年 2 月 6 日
I have an array as
A=[303
95
54
303
303]
I want to assign all same values as 1 and others as 0
A= [1
0
0
0
1
1]
  2 件のコメント
Stephen23
Stephen23 2016 年 2 月 6 日
編集済み: Stephen23 2016 年 2 月 6 日
This is the same basic task as your last question:
Did you try any of the answers? What information do you expect that those answers did not give you?
suchismita
suchismita 2016 年 2 月 6 日
yes sir that was working but i wanted only 303 to get assigned as 1, i guess in your code itself if i am not rounding the data i will get more appropriate answer.

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 6 日
newA = sum(bsxfun(@eq, A(:), A(:).')) > 1;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by