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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!