distance between a point and elements of a matrix
2 次查看(过去 30 天)
显示 更早的评论
Dear;
I am looking for an efficient way to compute the distance between coordinates (x,y,z) and the elements of a 3D matrix. For expample for a M3D[1:nx,1:ny,1:nz] I would like to get ahother 3D matrix Distance3D where each element in the new matrix will be:
M3D(ix,iy,iz)=sqrt((ix-x)^2+(iy-y)^2+(iz-z)^2);
Where ix runs for 1 to nx, so on.
Thanks in advance;
0 个评论
采纳的回答
更多回答(2 个)
Fei Deng
2017-4-17
Are you calculating the distance between coordinates (x,y,z) and the elements of a 3D matrix, OR the distance between coordinates (x,y,z) and the index of a 3D matrix? From your equation, it should be latter case, isn't it? In that case, I probably would just use 3 for-loops.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!