Keep only one set-cordinate (x,y) per x.

I have:
x y
1 2 <
1 3
1 3
2 4 <
2 4
2 6
3 7 <
3 8
5 6 <
5 8
I want to keep:
x y
1 2
2 4
3 7
5 6
How to do it in efficient way?

 Accepted Answer

xy=[1 2; 1 3; 1 3; 2 4; 2 4; 2 6; 3 7; 3 8; 5 6; 5 8];
[~,ind] = unique(xy(:,1))
xy(ind,:)

More Answers (1)

xy(1:2:end,:)

1 Comment

Jim Timon
Jim Timon on 31 Mar 2019
Edited: Jim Timon on 5 Apr 2019
I want to keep one set (x,y) per x number. I updated the question

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2018a

Asked:

on 31 Mar 2019

Answered:

on 5 Apr 2019

Community Treasure Hunt

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

Start Hunting!