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];

 Accepted Answer

a = [1 2 3 4 5 6 7];
b = [3 1 2 4 9 8 4];
c = b(~ismember(b, a))

More Answers (1)

a=[1 2 3 4 5 6 7];
b=[3 1 2 4 9 8 4]
out=setdiff(b,a,'stable')

3 Comments

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

Sign in to comment.

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Tags

No tags entered yet.

Asked:

on 13 Jul 2014

Answered:

Jan
on 13 Jul 2014

Community Treasure Hunt

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

Start Hunting!