Matrixr edundant rows removal

1 visualización (últimos 30 días)
Mohammad Farhat
Mohammad Farhat el 10 de Jul. de 2018
Comentada: Mohammad Farhat el 10 de Jul. de 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]

Respuesta aceptada

Paolo
Paolo el 10 de Jul. de 2018
Editada: Paolo el 10 de Jul. de 2018
newmatrix = oldmatrix(find(uniquetol(oldmatrix(:,1))),:)
  5 comentarios
Paolo
Paolo el 10 de Jul. de 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
Mohammad Farhat
Mohammad Farhat el 10 de Jul. de 2018
worked,thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by