필터 지우기
필터 지우기

How could I check that how many elements of x is inside y?

조회 수: 2 (최근 30일)
VIJENDRA
VIJENDRA 2015년 9월 23일
편집: Stephen23 2015년 9월 23일
Suppose I have
x = [2,7,8,11];
and
y = [1,2,4,5,7,8,9,12,15,21,27]
How could I check that how many elements of x is inside y?

채택된 답변

Stephen23
Stephen23 2015년 9월 23일
편집: Stephen23 2015년 9월 23일
You can use ismember:
>> x = [2,7,8,11];
>> y = [1,2,4,5,7,8,9,12,15,21,27];
>> ismember(x,y)
ans =
1 1 1 0
>> sum(ismember(x,y))
ans = 3

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by