Return equal values between sets.
1 次查看(过去 30 天)
显示 更早的评论
I have two vectors a and b of different lengths that contain integers. How can I return those values that belong in both a and b? Should I use ismember? ismember seems to return a vector of index numbers, but I could just that in a or b:
[tf, index] = ismember(a, b);
c = b(index);
c = a(index); %same?
0 个评论
采纳的回答
Wayne King
2011-9-21
How about intersect()?
x = 1:3;
y = 2:5;
[c,Ix,Iy] = intersect(x,y);
intersect() does not give repetitions though.
Wayne
更多回答(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!