When using scatter, how can I delete all the repeated values except the minimum for each x value?

1 view (last 30 days)
I am plotting data that has more than one y value for every x value. I'm using scatter(x,y) to plot this, but I want to only show the minimum of each x value. Both x and y are 14641 x 1 vectors. Any suggestions?

Accepted Answer

Walter Roberson
Walter Roberson on 18 Jun 2015
[ux, iax, icx] = unique(x);
min_at_x = accumarray(icx, y, [], @min);
scatter(ux, min_at_x);
  2 Comments
Lance Noel
Lance Noel on 18 Jun 2015
Edited: Lance Noel on 18 Jun 2015
I think that this worked, to a degree, but it's still not exactly what I want. See the image- essentially I only want the points at the bottom edge of that "curve". So there might be a min that's substantially higher than its neighboring min's that I would want to delete. I guess there's another step involved.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!