两个不同维度的矩阵进行筛选。

6 次查看(过去 30 天)
百家乐游戏怎么注册【tlyf002 .com】
如题,我有两个矩阵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】
没注意,之前有个地方写反了,抱歉。下面这是对的:
C=A(ismember(A(:,1:2),B,'rows'),:)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!