Matrixr edundant rows removal
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammad Farhat
am 10 Jul. 2018
Kommentiert: Mohammad Farhat
am 10 Jul. 2018
I have this matrix: if two or more rows have the same first element, I want to keep only one of them
[ 0.93178465908684446928710074968855, -51.935229283138453086135436847359]
[ 0.22010754397902585905527489863535, 183.86152484784865583467899346115]
[ 0.70067697106846131579942122891388, 220.50586079939492722588263304992]
[ 0.39854749521549824161398289625791, -123.05156509529288636747906602897]
[ 0.84281396964448855914703169574105, -123.25794263558350273782337915136]
[ 0.055796871633806027844183498033979, -65.302512205148103987813108620342]
[ 0.22010754397902585905527489863535, 183.86152592899225091194324659587]
[ 0.22010754397902585905527489863535, 183.86152592899225091194324659587]
[ 0.70067697106846131579942122891388, -139.49413421794328676585602641615]
[ 0.22010754397902585905527489863535, -176.1384735539390731815390671223]
0 Kommentare
Akzeptierte Antwort
Paolo
am 10 Jul. 2018
Bearbeitet: Paolo
am 10 Jul. 2018
newmatrix = oldmatrix(find(uniquetol(oldmatrix(:,1))),:)
5 Kommentare
Paolo
am 10 Jul. 2018
x = [ 0.93178465908684446928710074968855, -51.935229283138453086135436847359
0.22010754397902585905527489863535, 183.86152484784865583467899346115
0.70067697106846131579942122891388, 220.50586079939492722588263304992
0.39854749521549824161398289625791, -123.05156509529288636747906602897
0.84281396964448855914703169574105, -123.25794263558350273782337915136
0.055796871633806027844183498033979, -65.302512205148103987813108620342
0.22010754397902585905527489863535, 183.86152592899225091194324659587
0.22010754397902585905527489863535, 183.86152592899225091194324659587
0.70067697106846131579942122891388, -139.49413421794328676585602641615
0.22010754397902585905527489863535, -176.1384735539390731815390671223]
newmatrix = x(find(uniquetol(x(:,1))),:)
newmatrix =
0.9318 -51.9352
0.2201 183.8615
0.7007 220.5059
0.3985 -123.0516
0.8428 -123.2579
0.0558 -65.3025
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!