Dear;
I would like to calculate the 3D matrix of distances between one point an each element of a 3D matrix in an efficient way.
Without vectorization the code is:
MDistances=zeros(size(M)); for i=1:size(M,1) for j=1:size(M,2) for k=1:size(M,3) MDistances(i,j,k)=(i-ip)^2+(j-jp)^2+(k-kp)^2 end end end MDistances=sqrt(MDistances);
Thanks a lot!!
Best Answer