unique rows with nan

13 次查看(过去 30 天)
joseph Frank
joseph Frank 2011-7-1
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?

采纳的回答

Matt Fig
Matt Fig 2011-7-1
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by