unique rows with nan

17 visualizaciones (últimos 30 días)
joseph Frank
joseph Frank el 1 de Jul. de 2011
If i have two identical rows
for example: A=[ 1 2 3 NaN;1 2 3 NaN];
using
unique(A,'rows') is not eliminating the duplication. is there any other method to do so?

Respuesta aceptada

Matt Fig
Matt Fig el 1 de Jul. de 2011
This is because nan~=nan is always true.
So one approach is to replace nan with some other value.
A(isnan(A)) = inf;
B = unique(A,'rows');
B(isinf(B)) = nan
If you have infs in your array as well as nans, pick some other value.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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