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?

採用された回答

raym
raym 2017 年 6 月 6 日
Solvded already.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by