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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by