How to get Unique values from two columns at a time?
4 views (last 30 days)
Show older comments
Hello,
I have a matrix
0.075278 0.213 18 127
0.075278 0.220 16 127
0.075278 0.248 31 129
0.075278 0.307 22 129
0.075278 0.323 14 129
0.241944 0.217 26 129
0.241944 0.223 14 129
0.241944 0.487 22 129
0.241944 0.677 16 129
12.82861 0.247 12 135
If column 1 and 4 have unique values i need to keep only one and have to remove remaining
I want my answer as
0.075278 0.220 16 127
0.075278 0.323 14 129
0.241944 0.677 16 129
12.82861 0.247 12 135
0 Comments
Accepted Answer
Stephen23
on 16 Feb 2022
Edited: Stephen23
on 16 Feb 2022
M = [0.075278,0.213,18,127;0.075278,0.220,16,127;0.075278,0.248,31,129;0.075278,0.307,22,129;0.075278,0.323,14,129;0.241944,0.217,26,129;0.241944,0.223,14,129;0.241944,0.487,22,129;0.241944,0.677,16,129;12.82861,0.247,12,135]
[~,X] = uniquetol(M(:,[1,4]),'highest','ByRows',true);
N = M(X,:)
5 Comments
Stephen23
on 16 Feb 2022
Edited: Stephen23
on 16 Feb 2022
@LISSA DUVVU: please show the exact code that you tried.
Please check the help for your installed MATLAB version. Check the syntaxes that it supports. It may be that you need to also supply the tol argument, or something similar.
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!