How to calcululate the distance between 3D matrix elements to plane "Ax+By+Cz+D = 0" in a vectorized manner?
1 次查看(过去 30 天)
显示 更早的评论
I have a 3D matrix M
M = zeros(405,706,1932);
Suppose putting matrix M into the x-y-z coordinate,with the x-axis indicating the size(M)(1),y-axis indicating the size(M)(2), and z-axis indicating size(M)(3).
I also have a plane "Ax+By+Cz+D = 0" .
For each element in this matrix, calculate the distance to plane using (Ax0+By0+Cz0+D)/sqrt(A^2+B^2+C^2), then use the results to replace the element itself. So each element in M is the distance to this place.
The "for... for... for ..." cycle is too slow, how to vectorize this command?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!