How calculate distance between points in matrices?

3 次查看(过去 30 天)
Hi, I have 2 big matrices (m x 3) about 250000 points (xyz). These are coordinate of points. How find distance between some points as: a) from (0 to 10> mm, b) from (10 to 20> mm, c) from (20 to 30> mm, d) from (30 to 40> mm, e) above 40 mm. Next I want to find these distance and plot in colours: a) blue b) green c) yellow d) orange e) red. I suppose that there should be command find between matrices point to point and write to a matrix A_XYZxyz(n x 6), B, C, D. How to do in in very quick waY. Thnx

回答(1 个)

Bob Thompson
Bob Thompson 2018-8-3
The distance between two points can be determined using the Pythagorean theorem.
d = sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2);
In order to set colors you can use logic indexing.
color = cell(size(d));
color{d<10} = 'blue';
color{d>=10&d<20} = 'green';
... % Other colors
If you're wanting to actually set the colors in a plot, then just look up the color codes and set them accordingly.
  2 个评论
Matt J
Matt J 2018-8-3
Sebastian's comment moved here
Bob, I supposed that I need calculate a distance in this way. Maybe solution is analyse 1 matrice from 1st point to the end with another every point matrice. But if I have in 3 dimensional system, when 0 is inside in the block this calculation is useless (if Y=-4 and Y=4 it is the same). Maybe I need cut it in slices Z every 5 mm. Look at picture attached.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by