unique function in matlab
조회 수: 3(최근 30일)
In the version of R2012a, the unique function has a 'stable' property. Please see the link:
A = [9 2 9 5]; [C, ia, ic] = unique(A,'stable')
9 2 5
But my matlab version is R2010a, it seems that the unique function in R2010a does not support 'stable'. How can I get the stable result?
Albert Yam 2012년 7월 31일
I needed this as well, for R2007a
[uA a b] = unique(A,'first');
C = A(sort(a));
Sean de Wolski 2012년 7월 31일
The 'stable' option was introduced in R2012a.
One way to achieve something similar with an older release is to first sort the vector, then unique it and then index back into the original.
A = [9 2 9 5 5 4 4 1 1 1];
[As,idx] = sort(A);
[U,ij] = unique(As,'first');