两个不同维度的矩阵进行筛选。
显示 更早的评论
如题,我有两个矩阵A=[1,2,3;4,5,6;7,8,9;10,11,12;13,14,15;16,17,18;19,20,21]
B=[1,2;7,8;19,20]
我想用B的两列元素来筛选A,即得到C=[1,2,3;7,8,9;19,20,21]
请问怎么做比较方便快捷呢?我的数据样本很大,以上是个示意
回答(1 个)
百家乐注册【www.xbs3512.com】
2022-10-13
没注意,之前有个地方写反了,抱歉。下面这是对的:
C=A(ismember(A(:,1:2),B,'rows'),:)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!