check two matrix if its same display the matched value

2 次查看(过去 30 天)
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')

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by