Extracting certain rows from matrix

1 Ansicht (letzte 30 Tage)
Holmbrero
Holmbrero am 26 Nov. 2020
Bearbeitet: Holmbrero am 28 Nov. 2020
Hi!
I have a matrix T = 99x3
and another matrix S = 69x2
Column 1 in S contains 69 indices corresponding to certain rows in T.
I want to extract these certain rows from T.
I added T and S below if it is of any use.
Any suggestions?
Regards,
Anders Holmberg
T =
339.61084 -143.16057 111
284.86859 -138.91678 485
365.56125 -133.51691 52
250.24678 -128.58994 192
460.49060 -119.28328 1311
220.38821 -124.99724 291
402.10043 -100.26612 86
269.15973 -103.59526 77
48.892490 -97.207848 117
417.07434 -79.978699 101
187.08081 -77.885788 86
113.27888 -79.339539 318
377.89386 -70.904503 287
434.61917 -65.957199 111
222.04018 -51.015945 148
278.33923 -41.312492 360
192.16632 -36.322784 352
449.40820 -0.32173157 50
527.75635 3.2519226 98
247.66592 -2.5671539 171
52.336288 2.5239105 88
290.40799 45.803284 109
331.84909 48.412552 298
64.139572 41.363663 211
484.65219 75.356705 793
352.65259 86.140961 827
141.00993 89.940933 73
212.11679 93.171478 123
528.42822 114.36893 109
275.09943 117.24445 125
303.85611 118.75024 142
162.40082 115.57883 251
208.99135 133.63699 52
107.47208 131.01990 87
486.82513 147.78052 92
45.022820 140.10770 68
65.882324 141.83881 91
157.41364 151.30615 54
417.48654 179.65854 73
495.57526 189.12314 264
173.01447 184.80292 118
84.395302 185.42267 181
268.19031 198.25891 2339
188.60532 233.13608 95
307.06219 243.55441 134
409.77271 254.38382 75
535.34045 264.84848 80
199.89328 274.04797 130
427.29990 288.70758 61
124.71526 284.75168 236
238.95445 295.38330 241
66.018387 291.60770 62
525.46008 313.04959 54
342.86234 309.74478 181
451.90369 317.65396 113
184.68277 316.07016 72
88.001572 317.21487 359
342.33246 339.11392 186
466.92957 347.18741 147
447.57278 364.23392 112
38.267288 381.10654 121
350.61151 390.74979 61
185.59767 390.81161 327
401.47476 403.05112 63
477.08344 413.75864 114
216.17847 407.42050 53
197.22433 412.32925 50
433.87973 423.39633 227
351.18402 424.04507 56
496.71964 438.75052 57
323.06100 438.24460 65
458.87531 448.51480 107
411.87234 463.29196 64
409.67090 477.43430 55
479.94415 480.68350 89
385.68634 481.56119 82
68.477859 474.24637 134
365.15555 499.76822 109
51.827705 500.91153 491
441.38110 513.05688 93
313.61859 511.73685 293
489.67206 527.12720 77
469.25537 529.11475 104
45.060806 521.88428 64
178.43051 527.25415 63
405.94196 534.21155 50
365.80103 544.26172 99
299.29233 542.77942 53
428.75925 546.93799 83
321.20898 546.91052 118
281.35608 545.95459 64
443.13580 561.16504 135
372.81503 565.47021 394
342.58881 565.71057 101
320.95401 568.68372 239
142.13785 572.66260 766
382.30069 620.19373 130
320.73810 621.83838 79
204.94414 623.31323 57
S =
21 4.51076984405518
19 11.4743843078613
22 18.3587570190430
23 19.7070980072022
20 40.9994163513184
24 4.93227767944336
28 10.0483617782593
25 18.9996147155762
26 17.5263538360596
27 9.64306068420410
36 7.14353752136231
32 10.5398797988892
31 12.9565105438232
39 7.89259624481201
34 4.17205953598023
35 9.58878993988037
38 5.42349624633789
40 16.8424663543701
41 13.2013435363770
43 8.66385841369629
42 4.14684104919434
45 2.61139965057373
44 4.90659332275391
52 41.0211830139160
46 8.37653446197510
47 9.79308414459229
48 0.889725387096405
51 11.3225593566895
54 14.2948379516602
55 16.9351272583008
53 6.65440511703491
57 1.60811495780945
60 6.60633993148804
59 9.26866054534912
66 4.73961162567139
61 16.9218845367432
62 5.54498147964478
63 15.1520271301270
71 1.54938817024231
64 1.25193774700165
67 4.36905956268311
68 4.84249830245972
69 3.70246767997742
77 60.2132148742676
72 0.768628180027008
79 8.64342212677002
73 3.06259489059448
74 3.60962963104248
76 1.92712450027466
75 9.99215793609619
78 5.07191514968872
81 7.84966564178467
80 4.91810417175293
85 4.66130638122559
83 10.4304790496826
86 3.68249464035034
88 1.01345729827881
87 1.68117392063141
91 1.43024551868439
90 0.118958853185177
89 3.94388508796692
92 3.46568751335144
93 0.671901702880859
94 0.458056718111038
95 1.00567424297333
96 8.87801361083984
97 1.72155869007111
98 7.82691860198975
99 43.8082580566406

Akzeptierte Antwort

KSSV
KSSV am 26 Nov. 2020
Read about ismember.
  1 Kommentar
Holmbrero
Holmbrero am 26 Nov. 2020
Bearbeitet: Holmbrero am 28 Nov. 2020
Hi and thank you for your answer.
I think ismember is a part of the solution but i need to rephrase my question.
I want to extract these certain rows from T and add them to a new matrix in the same order as they were in T.
This should give me a new matrix with 69 rows.
As far as i know, ismember only tells me if the value is present in the two matrices.
Any help would be appriciated!
Edit:
It can be solved using ismember as KSSV wrote above.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by