문제

I have a cube of 20*20*20 cm^3 and voxels of 1cm^3, how do I get the coordinates of all the 20*20*20=8000 voxel centers as a list of [x,y,z] (size 8000*3)? Preferably in vectorized form! Thanks a lot!

도움이 되었습니까?

해결책

ndgrid does the job:

N = 20;
[z, y, x] = ndgrid(.5:N); %// note reverse order to get desired order of result
xyz = [x(:) y(:) z(:)]; %// desired result
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top