How to calcululate the distance between 3D matrix elements to plane "Ax+By+Cz+D = 0" in a vectorized manner?

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

raym
raym el 6 de Jun. de 2017
Solvded already.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by