using boundary command from matlab R2015a

4 views (last 30 days)
imola
imola on 7 Jun 2015
Edited: Walter Roberson on 29 Dec 2017
Dear All,
I'm trying to find the boundary for a set of points for dimension n=>2, so I start with dimension 2. This code is from matlab tool box, why the command boundary doesn't work in my version R2013a or R2014a or R2012b, it gave this answer
Undefined function 'boundary' for input arguments of type 'double'.
I need to find the boundary without using the convhull command even in high dimensions. Can anyone answer me which is the appropriate method and why boundary command doesn't work.
x = gallery('uniformdata',30,1,1);
y = gallery('uniformdata',30,1,10);
plot(x,y,'.')
xlim([-0.2 1.2])
ylim([-0.2 1.2])
k = boundary(x,y);
hold on;
plot(x(k),y(k));
Thanks in advance, Imola.

Answers (2)

Walter Roberson
Walter Roberson on 7 Jun 2015
  9 Comments
imola
imola on 10 Jun 2015
Dear Walter,
I'm not allowed to use convexhulln in my work. i have set of points and i want to check them inside a shape, when i check a large set that's will consume time so i decided to take the points in the border that's faster. now i think in 2-3 dimensions hopefully not bad but i will need to find it in high dimensions. I finally install R2015a and i run my code from there now i test it in 2-dimensions is good, but i need to run my code from R2012b which is faster and give better result from it. I decided to take the code of boundary from R2015a to use it in R2012b but still have problem to get some functions deal with the code (criticalAlpha and alphaShape) i'm trying to get them and use them in R2012b. If you have an idea how to get them because the function boundary it was easy to get it but these i search a lot for them inside the files and i tried to open them from command window by call them with wrong input and it failed.
Many thanks Walter and Image Analyst you help me a lot.
regards,
Walter Roberson
Walter Roberson on 10 Jun 2015
Why are you not allowed to use convexhulln? Is this an assignment intended to have you think about how to implement convex hulls yourself? Or is the routine continued to be too expensive? Or is it a patent issue of some kind?
Given a non-convex shape defined only by vertices, what does it mean for a point to be "inside" it or "outside" of it?
Given any finite set of infinitely-small points and any given point in the list, it is always possible to find a viewpoint from "outside" in which the distinguished point is directly visible, not hidden behind some other point. More formally, given any point in the finite list, it is possible to create a ray from the point to infinity that does not intersect any other point in the list. Thus it is always possible to rotate and translate the cloud so that any given point is at the origin and one is looking down to it from "above" and there are no other points in the way to that origin. Project all the other points onto the x-y plane, and you will have a finite set of points "around" the origin. Take the subset of those points that would be "above" the x-y plane from the view and make a surface from those that does not cross the origin, so that the point at the origin is at the bottom of a "well". That is one valid interpretation of what the point cloud "means", that the well was "always there" and you just didn't realize it because you were looking from a direction that was hiding the walls of the well. From this perspective, with that point at the bottom of the well -- the point at the origin, the distinguished point -- is exactly on the surface.
We thus find that given any cloud of points, we can find a perspective and covering in which any given point in the cloud is on the surface of a covering of the cloud.
Now given any particular test point, is it "inside" the cloud or outside of it? Provided the point is not identical to any other point, provisionally add it to the list, rotate and center the right way, establish the covering in which the point would be on the surface. But the point wasn't originally part of the set, so therefore that point must be on the outside. By induction, every test point that is not identical to one of the original points can be shown to be outside of some covering of the cloud.
Unless, that is, you establish rules about how the points have to be connected. The most easily justified of those rules is to declare that the resulting surface must be convex; this is the surface that would be found by convexhulln()... whether you program the routine yourself or use the library routine, imposing the convex requirement gives very clear conditions that are difficult to argue with.

Sign in to comment.


doreminh
doreminh on 29 Dec 2017
Edited: Walter Roberson on 29 Dec 2017
I tried by this way, it's good,can reply for boundary function:
x = randn(250,1);
y = randn(250,1);
DT = delaunayTriangulation(x,y);
k = convexHull(DT);
n=length(k(:));
for i=1:n
bd(i,1)=x(k(i));
bd(i,2)=y(k(i));
end
figure
fill(bd(:,1),bd(:,2),'r')
hold on
plot(DT.Points(:,1),DT.Points(:,2), '.','markersize',10);
hold on
plot(DT.Points(k,1),DT.Points(k,2),'r')

Community Treasure Hunt

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

Start Hunting!