Domanda

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!

È stato utile?

Soluzione

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top