How to get Unique values from two columns at a time?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Stephen23
il 16 Feb 2022
Modificato: Stephen23
il 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 Commenti
Stephen23
il 16 Feb 2022
Modificato: Stephen23
il 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!