필터 지우기
필터 지우기

array. find if one element or another is in the array

조회 수: 3 (최근 30일)
Patrick Brown
Patrick Brown 2017년 2월 1일
답변: Star Strider 2017년 2월 1일
Hi, I have to vectors A and B I want to find if the elements of B are in A if whatever of the elements of B are in A, I want to get a 1 in the position where the element is if not a 0
for example A=[1 2 3 4 5] B=[1 3] c= 1 0 1 0 0
thanks

채택된 답변

Star Strider
Star Strider 2017년 2월 1일
The ismember function does exactly that:
A=[1 2 3 4 5];
B=[1 3];
Out = ismember(A, B)
Out =
1×5 logical array
1 0 1 0 0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by