Check if random (x,y) coordinates exist in separate x vector and y vector

I have a vector of x coordinates (called circox) and a vector of corresponding y coordinates (called circoy). I then generate a random x and y coordinate and need to check if these coordinates already exist as a pair in circox and circoy. If they already exist I will reject them. In pseudo code I am trying to achieve this:
circox = (x1, x2, x3, ...40 values)
circoy = (y1, y2, y3, ...40 values)
x = rand
y = rand
if ((x,y) appears as a pair in (circox,circoy)),
reject x and y;
else
accept x and y;
end
Just need to figure out the if part. In theory I could loop through each position in circox and circoy, checking if it matches the randomly generated (x,y) coordinates but I'm hoping there's a neater function built into MATLAB.
Any ideas?

 채택된 답변

Walter Roberson
Walter Roberson 2014년 4월 9일

0 개 추천

ismember() with the 'rows' option.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2014년 4월 9일

댓글:

2014년 4월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by