Depending on how literal your example is, the disp will be a massive overhead (I/O is very slow).
That aside, I believe the quickest way to do a check like this is:
if find(primes==3,1,'first')
disp('yes');
else
disp('no');
end
Edit, you could also use any(primes==3) - a quick speed test shows they're approximately equivalent:
>> biglist = 1:100000;
>> tic;for i=1:10000
find(biglist==i,1,'first');
end
toc
Elapsed time is 1.055928 seconds.
>> tic;for i=1:10000
any(biglist==i);
end
toc
Elapsed time is 1.054392 seconds.