Finding rows where the first column values are equal
16 次查看(过去 30 天)
显示 更早的评论
Array A:
13453 10359 9955
5257 5299 5258
5849 3644 5848
5397 7230 5396
17132 17130 17118
4767 4768 4770
8291 8292 8316
3191 3190 15970
13389 14409 14410
14840 13022 13021
Array B:
13453 12292 9955 10359
6805 3039 3012 3011
2005 8087 2394 17740
5257 5258 5299 2012
6309 6290 6310 6289
5849 5811 5848 3644
5397 7230 8425 5396
4775 4760 6529 1118
17132 17130 13938 17118
4767 4791 4770 4768
8291 8292 5145 8316
3191 3190 14432 15970
10539 14895 9170 10540
13389 14409 9927 14410
14840 14387 13021 13022
Expected output: Indices of rows in Array B where the first column value is the same as Array A:
1
4
6
7
9
10
11
12
14
15
When I try to use ismember, I get an error that "arrays have incompatible sizes".
x = find (B(:,1) == A (:,1));
0 个评论
采纳的回答
Arif Hoq
2022-3-7
编辑:Arif Hoq
2022-3-7
A=[13453 10359 9955
5257 5299 5258
5849 3644 5848
5397 7230 5396
17132 17130 17118
4767 4768 4770
8291 8292 8316
3191 3190 15970
13389 14409 14410
14840 13022 13021];
B=[13453 12292 9955 10359
6805 3039 3012 3011
2005 8087 2394 17740
5257 5258 5299 2012
6309 6290 6310 6289
5849 5811 5848 3644
5397 7230 8425 5396
4775 4760 6529 1118
17132 17130 13938 17118
4767 4791 4770 4768
8291 8292 5145 8316
3191 3190 14432 15970
10539 14895 9170 10540
13389 14409 9927 14410
14840 14387 13021 13022];
Output=find(ismember(B(:,1),A(:,1)))
16 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!