check two matrix if its same display the matched value

i'm checking this two matrix a,b if it's same element than display the matched value and again the matched value only should get deleted and than it that should display what are all the values din't matched with 'b'(it means after deleting the remaining matrix should display).
a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4];
Note: i'm compering 'a' with 'b'.
answer should be
c=[9 8];

 채택된 답변

Jan
Jan 2014년 7월 13일
a = [1 2 3 4 5 6 7];
b = [3 1 2 4 9 8 4];
c = b(~ismember(b, a))

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 13일
편집: Azzi Abdelmalek 2014년 7월 13일
a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4]
out=setdiff(b,a,'stable')

댓글 수: 3

i'm getting error
??? Error using ==> setdiff at 140 Unknown flag.
Try this
a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4]
[ii,jj]=setdiff(b,a)
[~,idx]=sort(jj)
out=ii(idx)
ya i'm getting thank you

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2014년 7월 13일

답변:

Jan
2014년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by