How to use Uniquetol without sorting?

39 ビュー (過去 30 日間)
AMEHRI WALID
AMEHRI WALID 2019 年 7 月 12 日
コメント済み: Min Zhang 2021 年 11 月 23 日
Hello everyone,
I'm using the function "Uniquetol" to remove the duplicate vector from a matrix A which the size is (3, 10).
B = ( uniquetol(A', 1e-6, 'ByRows', 1) )';
It works very well, but it is also sorting my matrix which what I don't want
Please, can anyone tell how can we use the function "Uniquetol" without sorting ?

採用された回答

Guillaume
Guillaume 2019 年 7 月 12 日
[~, colindices] = uniquetol(A', 1e-6, 'ByRows', true); %get indices of unique value. Is sorted BY VALUE
B = A(:, sort(colindices)) %Use the indices sorted BY INDEX instead
  4 件のコメント
Bruno Luong
Bruno Luong 2020 年 10 月 28 日
Both solutions are equally valid. They respect the order in the original matrix.
Sorry Huy, there is not reason your solution is right and other is wrong.
Min Zhang
Min Zhang 2021 年 11 月 23 日
Try this:
A = [0.05 0.11 0.18; ...
0.46 0.52 0.76;...
0.34 0.36 0.41; ...
0.18 0.21 0.29; ...
0.46 0.52 0.76;...
0.05 0.11 0.18;];
%
[~, colindices] = uniquetol(A, 'ByRows', true)
sort(colindices)
% get indices of unique value. Is sorted BY VALUE
B = A(sort(colindices),:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by