Uniquetol which preserves the first occurance
1 次查看(过去 30 天)
显示 更早的评论
I'm using the uniquetol function to filter some data by rows. Here each column gives a weight value with respect to a specific basis function, and therefore each row gives the set of weights related to a specific function:
[~,index] = uniquetol(DATA,2.5e-1,'ByRows',true);
The DATA is sorted beforehand so the 'simplest' function is in row 1, and the most 'complex' function is in row N, with the practical aim being to exclude any 'complex' functions which are within tolerence to a simpler counterpart.
For this purpose, I'm looking for a way to ensure the index values output correspond to the first occurance in the DATA matrix, rather than choosing the 'highest' or 'lowest' occurance.
I searched the file-exchange, but there are a suprisingly large variety of unique-tolerence functions so I may have missed a valid existing solution.
0 个评论
采纳的回答
Bruno Luong
2022-5-31
编辑:Bruno Luong
2022-5-31
Use the third inputs followed by accumarray
% Dummy data
n = 100;
A = randi(10,1,n)+1e-12*rand(1,n)
[~,~,J]=uniquetol(A);
firstidx = accumarray(J,(1:length(J))',[],@min)
% Check
A(firstidx)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!