필터 지우기
필터 지우기

Matrixr edundant rows removal

조회 수: 2 (최근 30일)
Mohammad Farhat
Mohammad Farhat 2018년 7월 10일
댓글: Mohammad Farhat 2018년 7월 10일
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
Mohammad Farhat
Mohammad Farhat 2018년 7월 10일
worked,thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by