How to calcululate the distance between 3D matrix elements to plane "Ax+By+Cz+D = 0" in a vectorized manner?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!