MATLAB: Unique rows with nan unique 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? Best Answer 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)) = nanIf you have infs in your array as well as nans, pick some other value. Related SolutionsMATLAB: Correlation between two row matrices Like that, each value of "a" is correlated to each value of "b", but applying the formula of the correlation, the correlation of two single numbers is NaN. To compute the correlation correctly, traspose the input vectorsresult = corr(a', b'); MATLAB: Using unique.m function on NaNs No. It's supposed to be a.By definition nans are not equal to themselves so they're not equal in rows either.isequal(nan,nan)ornan==nan Related QuestionSame matrix but not equal problemUnique commandHelp with removing duplicate sub-elements….About unique command problemSubtract two matrices each with NaN values in different cellsSelecting unique rows
Best Answer