% 1. use vectors instead of the for loop to calculate distance, example
dist = sqrt(x.-xCenter).^2.+(y.-yCenter).^2.+(z.-zCenter).^2);
% 2. use 'find' for criteria <=vt^2. make some changes to the two lines
find(dist <=vt^2).
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!