How can I delete numbers in a matrix that is not equal to numbers in another matrix?
조회 수: 3 (최근 30일)
이전 댓글 표시
I know the title may be a little confusing.Say I have A =[1 2 2 3 3 4 4 ] and B = [2 3 4], how can I make A 'realize ' that there is a number in it different from B and delete it? Is there any simple way to do that? I want to avoid loops......Thanks!
댓글 수: 0
답변 (1개)
Lessmann
2015년 11월 5일
Hi,
you can use logical indexing with the 'ismember' function:
A= A(ismember(A,B))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!