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

2 Ansichten (letzte 30 Tage)
suchismita
suchismita am 6 Feb. 2016
Kommentiert: suchismita am 6 Feb. 2016
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 Kommentare
Stephen23
Stephen23 am 6 Feb. 2016
Bearbeitet: Stephen23 am 6 Feb. 2016
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 am 6 Feb. 2016
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Feb. 2016
newA = sum(bsxfun(@eq, A(:), A(:).')) > 1;

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by