两个不同维度的矩阵进行筛选。
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
如题,我有两个矩阵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]
请问怎么做比较方便快捷呢?我的数据样本很大,以上是个示意
0 Kommentare
Antworten (1)
百家乐注册【www.xbs3512.com】
am 13 Okt. 2022
没注意,之前有个地方写反了,抱歉。下面这是对的:
C=A(ismember(A(:,1:2),B,'rows'),:)
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!