extract data from table

12 次查看(过去 30 天)
kaikkkkkk
kaikkkkkk 2020-11-4
评论: kaikkkkkk 2020-11-4
Suppose i have
23points of xy coordinate , where 1st column is X coordinate , 2nd column is Y coordinate , it is a 23x2 matrix,
I have another seperate data to tell me which 5 points to take.
is there anyway i can do a neat work instead of for loop ? Because i need to calculate the distance using for loop later on and with hundreds of points which is lagging my system.
i wish to print out the 5 points , and have result of the x y coordinate into 1 matrix. lets says i wish to get point 2 , 3 , 5 , 8 , 9 base on 1st column of table 2
table 1
10.6100 16.9500
27.0800 18.6300
41.2900 18.2600
60.5000 20.1700
1.7800 11.5200
16.8500 11.1000
29.9500 11.8500
46.6400 11.4900
60.5000 11.8000
8.3500 5.1600
40.3900 6.8300
55.0000 7.1200
2.9800 19.3000
15.3600 16.1600
12.9900 20.2000
44.5700 21.2000
25.4900 4.6500
41.5800 14.9900
50.9100 14.3700
50.5000 20.0200
60.5000 14.6500
2.6800 4.8800
63.0200 3.8600
table 2
2 4 4 4
3 20 9 21
5 21 21 20
8 19 19 19
9 16 20 16
Expecting Results from table from 1 with reference to first row of table 2 :
27.0800 18.6300
41.2900 18.2600
1.7800 11.5200
46.6400 11.4900
60.5000 11.8000

采纳的回答

KSSV
KSSV 2020-11-4
LEt A, B be your two matrices.
iwant = A(B(:,1),:);
  4 个评论
KSSV
KSSV 2020-11-4
Read about pdist2. This will give your distances on providing two set of points.
kaikkkkkk
kaikkkkkk 2020-11-4
yes i understand pdist2 calculate euclidean distance between 2 points.
thank you for your help.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by