How to draw a smaller boundary?

I have a two column data of Te2000 and Ar2000. I can plot the points and their boundary without any issue like this:
plot(Te2000, Ar2000, 'b.')
k1 = boundary(Te2000,Ar2000);
hold on;
plot(Te2000(k1), Ar2000(k1));
My goal is to get a tighter boundary that only covers 90% of the points, so I tried the below code:
plot(Te2000, Ar2000, 'b.')
k1 = boundary(Te2000,Ar2000);
hold on;
plot(Te2000(k1), Ar2000(k1), 0.75);
Why do I get this below error?
Error using plot
Data must be a single matrix Y or a list of pairs X,Y.

 Accepted Answer

Walter Roberson
Walter Roberson on 27 Feb 2018
Edited: Walter Roberson on 27 Feb 2018

7 Comments

Many thanks! I just tried and it worked. Here is the thing. I want to find a boundary which covers 90% of the data points, but it seems that right now the boundary covers 100% of the data points, and my only choices are either draw a smaller or larger boundary. How do I keep the outliers data with larger uncertainties out of the boundary?
You run into questions about what is an outlier and what is part of the regular data.
One approach is to take the centroid of the data, then convert the coordinates of all points to polar relative to the centroid. Sort by distance. Take 90% of the way through the list. Delete the points in the last 10% from the list of coordinates. boundary() the rest.
That's exactly what I want. Do you have codes to perform this? What functions should I use to convert the coordinates to polar relative to the centroid?
Many thanks.
centroid_x = mean(x_coordinates);
centroid_y = mean(y_coordinates);
[~,r] = cart2pol( x_coordinates - centroid_x, y_coordinates - centroid_y);
[~, sortidx] = sort(r);
top90 = sortidx(1:floor(length(sortidx)*9/10));
subset_x = x_coordinates(top90);
subset_y = y_coordiantes(top90);
now you can find the boundary on subset_x subset_y
Many thanks for the big help! I really appreciate it.
If you're using release R2017a or later, check if any of the methods available in the isoutlier function detects outliers in such a way that matches your intuition and/or expectations.
Many thanks for the tip!

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Tags

Asked:

on 27 Feb 2018

Commented:

on 28 Feb 2018

Community Treasure Hunt

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

Start Hunting!