【问题标题】:Find rows in B not in A在 B 中查找不在 A 中的行
【发布时间】:2018-02-20 17:31:19
【问题描述】:

矩阵 A(100,3) 和 B(1000,3)。我想获得 1) B 中不包含在 A 中的行及其索引,2) B 中的行 & 存在于 A 中的行及其索引。

A=randi([1 5],100,3)
B=randi([1 5],1000,3)
[a b]=intersect(A,B)
[c d]=~intersect(A,B)

如何放置以便获得行索引。

【问题讨论】:

    标签: arrays matlab member


    【解决方案1】:

    您可以将setdiffintersect'rows' 选项一起使用:

    [inBnotA, inBnotAindex] = setdiff(B, A, 'rows');
    [inBandA, inBandAindex] = intersect(B, A, 'rows');
    

    【讨论】:

    • setxor 是另一个具有类似应用的函数(与intersect 相反)。
    猜你喜欢
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-20
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多