how to tell if two elements in an array are identical

조회 수: 9 (최근 30일)
Milan Parsotam
Milan Parsotam 2018년 9월 6일
편집: Milan Parsotam 2018년 9월 22일
Hi all I need help on this. I am rather new to matlab so im sure this is an easy fix, but how would i write a code/ is there a function pre existing on matlab that is able to detect if any two(or more) elements in an array are identical, and if possible how to change the identical values

채택된 답변

madhan ravi
madhan ravi 2018년 9월 6일
편집: madhan ravi 2018년 9월 6일
Use:
isequal(A,B) %to check they are the same.
Or
A=1:5
B=[1 4 5 2 8] % to find where they are identical
index=find(ismember(A,B))
%this command represents A which is in B
  댓글 수: 2
Milan Parsotam
Milan Parsotam 2018년 9월 6일
편집: Milan Parsotam 2018년 9월 22일
Hey, thanks very much for the quick feedback. i have worked on my code since, developing this
commonxvalues=ismember(xpoint,points);
commonyvalues=ismember(ypoint,points);
if ismember(commonxvalues,1)==0
points(counter,1)= xpoint;
end
if ismember(commonyvalues,1)==0
points(counter,2)= ypoint;
end
how do I make it so that common values returns a logical array cheers
madhan ravi
madhan ravi 2018년 9월 6일
provide all your datas by pasting it here

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by