Matrixr edundant rows removal

1 次查看(过去 30 天)
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]

采纳的回答

Paolo
Paolo 2018-7-10
编辑:Paolo 2018-7-10
newmatrix = oldmatrix(find(uniquetol(oldmatrix(:,1))),:)
  5 个评论
Paolo
Paolo 2018-7-10
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by