One way you can check to be certain that no two positions are the same is to be certain that the positions are unique:
foodRows = 0;
while foodRows < 20
fxPos=randi(200,20,1);
fyPos=randi(200,20,1);
food=[fxPos fyPos];
[Ufood,~,ix] = unique(food, 'rows');
foodRows = size(Ufood,1)
end
That may be the easiest (and likely most efficient) option.
