Jurriën
Jurriën

Reputation: 309

Matlab connect outer boundary points in plot

Please find attached a footprint plot of a missile trajectory. I want to connect the most outer points of the plot, like this: http://nl.mathworks.com/help/matlab/ref/boundary.html . Problem is this boundary function has been implemented in matlab 2014. Unfortunatly, I have to deal with Matlab 2013a... How can I achieve the same plots as the newer boundary function? My plot-command is simply:

plot(x,y)

Thanks in advance. enter image description here

edit: I used the convhull command. According to the description it should do the job. However, something is going wrong. the code:

figure(4)
subplot(1,2,1);
plot(y_array,x_array,'b*');
k=convhull(y_array,x_array);
subplot(1,2,2);
plot(x(k),y(k),'r-')

The same error occcures when using:

DT=delaunayTriangulation(y_array',x_array');
[K,v]=convexHull(DT);
subplot(1,2,2);
plot(x(K),y(K),'r')

enter image description here

Upvotes: 1

Views: 1226

Answers (1)

akamath
akamath

Reputation: 570

I would try using convhull on it. From https://www.mathworks.com/help/matlab/ref/convhull.html, this is how you can plot the convex hull (if that's what you mean by 'outer points'):

xx = -1:.05:1;
yy = abs(sqrt(xx));
[x,y] = pol2cart(xx,yy);
k = convhull(x,y);
plot(x(k),y(k),'r-',x,y,'b*')

convhull was introduced before R2006a, and so should work on your version.

convhull

Upvotes: 3

Related Questions