Why not
primes(1000)
For an alternative solutions, check the code here: https://www.mathworks.com/matlabcentral/fileexchange/32774-this-program-finds-prime-numbers-manually
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!