How to do set subtraction

92 visualizaciones (últimos 30 días)
Mohammad Golam Kibria
Mohammad Golam Kibria el 12 de Dic. de 2012
I have two array a=[1,2,3] and b=[2,3,4,5]
I need a array c=b\a. Here \ is the set subtract operation. result is as follows:
i.e.c=[4,5]
How to do that in matlab. Thanks in advance.

Respuesta aceptada

Matt Fig
Matt Fig el 12 de Dic. de 2012
Editada: Matt Fig el 12 de Dic. de 2012
a = 1:3;
b = 2:5;
c = setdiff(b,a)

Más respuestas (1)

Vishal Rane
Vishal Rane el 12 de Dic. de 2012
Use
c = b(~ismember(b,a))
although there might be more simpler way to do this.

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by