extract data from table

12 views (last 30 days)
kaikkkkkk
kaikkkkkk on 4 Nov 2020
Commented: kaikkkkkk on 4 Nov 2020
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

Accepted Answer

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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!