Deleting non identical values of 2 vectors?

1 visualización (últimos 30 días)
Mirko Tomic
Mirko Tomic el 4 de Jul. de 2022
Editada: MJFcoNaN el 4 de Jul. de 2022
Hi, i have 2 vectors:
a = [5 6 1 8 4 7 3]
b = [4 5 6 2]
the outcome i need is --> a = [5 6 NaN Nan 4 NaN NaN]

Respuesta aceptada

MJFcoNaN
MJFcoNaN el 4 de Jul. de 2022
Editada: MJFcoNaN el 4 de Jul. de 2022
Hello,
The function of ismember may help you
a = [5 6 1 8 4 7 3];
b = [4 5 6 2];
[lia,locb]=ismember(a,b);
a(~lia)=NaN
a = 1×7
5 6 NaN NaN 4 NaN NaN

Más respuestas (0)

Categorías

Más información sobre Tables 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