First off, you have ans set to true in both cases. So change the else statement to be equal to false. Other than that your function should work.
Then call the function like this:
or if you are looping through a database:
answer = double(num);
for i = 1:num
answer(i) = eligible(v(i),q(i));