Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Boundary of group of points

Subject: Boundary of group of points

From: John

Date: 19 Mar, 2009 19:26:02

Message: 1 of 10

I have a series of X,Y coordinates:

X = [1,2,3,4,1,2,34,1,2,3,4];
Y = [100,100,100,100,200,200,200,200,300,300,400,400];

I'm trying to determine which points lie on the edge of the "area" created by these points.

The results should look like:

Xa = [1,2,3,4,4,3,2,1]
Ya = [100,100,100,100,400,400,300,300]

The output will be a line plotted around the border of these points.


Any suggestions? I've been using the PATCH command to overlay the border, but I haven't been able to reduce my dataset down appropriately.

Thanks!

John

Subject: Boundary of group of points

From: us

Date: 19 Mar, 2009 19:36:01

Message: 2 of 10

"John"
> I have a series of X,Y coordinates:
> X = [1,2,3,4,1,2,34,1,2,3,4];
> Y = [100,100,100,100,200,200,200,200,300,300,400,400];
> I'm trying to determine which points lie on the edge of the "area" created by these points...

a hint:

     help convhull;

us

Subject: Boundary of group of points

From: Roger Stafford

Date: 19 Mar, 2009 19:42:02

Message: 3 of 10

"John" <johnsengenberger@hotmail.com> wrote in message <gpu68a$nat$1@fred.mathworks.com>...
> I have a series of X,Y coordinates:
>
> X = [1,2,3,4,1,2,34,1,2,3,4];
> Y = [100,100,100,100,200,200,200,200,300,300,400,400];
>
> I'm trying to determine which points lie on the edge of the "area" created by these points.
> The results should look like:
>
> Xa = [1,2,3,4,4,3,2,1]
> Ya = [100,100,100,100,400,400,300,300]
>
> The output will be a line plotted around the border of these points.
> Any suggestions? I've been using the PATCH command to overlay the border, but I haven't been able to reduce my dataset down appropriately.
> Thanks!
> John

  If you hadn't included (2,300), I would have advised using 'convhull'. As things stand, you will have to define exactly what you mean by "the border of these points". What is your criterion for including (2,300) in the plot?

Roger Stafford

Subject: Boundary of group of points

From: Roger Stafford

Date: 19 Mar, 2009 19:59:01

Message: 4 of 10

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gpu76a$snp$1@fred.mathworks.com>...
> If you hadn't included (2,300), I would have advised using 'convhull'. As things stand, you will have to define exactly what you mean by "the border of these points". What is your criterion for including (2,300) in the plot?

  Also why include (2,100) and (3,100) while leaving out (1,200) and (4,200)? What is your criterion there?

Roger Stafford

Subject: Boundary of group of points

From: John

Date: 19 Mar, 2009 20:12:01

Message: 5 of 10

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gpu76a$snp$1@fred.mathworks.com>...
> "John" <johnsengenberger@hotmail.com> wrote in message <gpu68a$nat$1@fred.mathworks.com>...
> > I have a series of X,Y coordinates:
> >
> > X = [1,2,3,4,1,2,34,1,2,3,4];
> > Y = [100,100,100,100,200,200,200,200,300,300,400,400];
> >
> > I'm trying to determine which points lie on the edge of the "area" created by these points.
> > The results should look like:
> >
> > Xa = [1,2,3,4,4,3,2,1]
> > Ya = [100,100,100,100,400,400,300,300]
> >
> > The output will be a line plotted around the border of these points.
> > Any suggestions? I've been using the PATCH command to overlay the border, but I haven't been able to reduce my dataset down appropriately.
> > Thanks!
> > John
>
> If you hadn't included (2,300), I would have advised using 'convhull'. As things stand, you will have to define exactly what you mean by "the border of these points". What is your criterion for including (2,300) in the plot?
>
> Roger Stafford

------------------------------

Roger,

I'm trying to end up with a "city block" type out output - I'd like to have only vertical and horizontal lines... which means I might need to clarify that example. The inputs and outputs should be:

X = [1,2,3,4,1,2,3,4,1,2,3,4,3,4];
Y = [100,100,100,100,200,200,200,200,300,300,300,300,400,400];

Xa = [1,4,4,3,3,1]
Ya = [100,100,400,400,300,300]

Thanks,

John

Subject: Boundary of group of points

From: us

Date: 19 Mar, 2009 20:14:02

Message: 6 of 10

"Roger Stafford"
> > If you hadn't included (2,300), I would have advised using 'convhull'. As things stand, you will have to define exactly what you mean by "the border of these points". What is your criterion for including (2,300) in the plot?
> Also why include (2,100) and (3,100) while leaving out (1,200) and (4,200)? What is your criterion there...

roger,
i guess the OP was a bit hasty and produced a typo in his/her X, which (probably) should read

     x=[1,2,3,4,1,2,3,4,1,2,3,4]; % <- note: 34 ==> 3,4
     y= [100,100,100,100,200,200,200,200,300,300,400,400];
     xa=[1,2,3,4,4,3,2,1];
     ya=[100,100,100,100,400,400,300,300];
% now, when looking at the data
     line(x,y,'marker','s','linestyle','none','markerfacecolor',[1,1,0]);
% -and-
     ix=convhull(x,y);
     line(x(ix),y(ix),'marker','o','markerfacecolor',[0,0,0],'color',[0,0,0]);
% -and- comparing with what he/she wants
     line(xa,ya,'marker','+','linewidth',2,'color',[1,0,0]);
     set(gca,'xlim',[0,5],'ylim',[0,500]);
% he/she probably needs an alpha shaper...
% eg,

http://www.mathworks.com/matlabcentral/fileexchange/6760

just a thought
urs

Subject: Boundary of group of points

From: Roger Stafford

Date: 19 Mar, 2009 20:38:01

Message: 7 of 10

"John" <johnsengenberger@hotmail.com> wrote in message <gpu8uh$q$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gpu76a$snp$1@fred.mathworks.com>...
> > "John" <johnsengenberger@hotmail.com> wrote in message <gpu68a$nat$1@fred.mathworks.com>...
> > > I have a series of X,Y coordinates:
> > >
> > > X = [1,2,3,4,1,2,34,1,2,3,4];
> > > Y = [100,100,100,100,200,200,200,200,300,300,400,400];
> > >
> > > I'm trying to determine which points lie on the edge of the "area" created by these points.
> > > The results should look like:
> > >
> > > Xa = [1,2,3,4,4,3,2,1]
> > > Ya = [100,100,100,100,400,400,300,300]
> > >
> > > The output will be a line plotted around the border of these points.
> > > Any suggestions? I've been using the PATCH command to overlay the border, but I haven't been able to reduce my dataset down appropriately.
> > > Thanks!
> > > John
> >
> > If you hadn't included (2,300), I would have advised using 'convhull'. As things stand, you will have to define exactly what you mean by "the border of these points". What is your criterion for including (2,300) in the plot?
> >
> > Roger Stafford
>
> ------------------------------
>
> Roger,
>
> I'm trying to end up with a "city block" type out output - I'd like to have only vertical and horizontal lines... which means I might need to clarify that example. The inputs and outputs should be:
>
> X = [1,2,3,4,1,2,3,4,1,2,3,4,3,4];
> Y = [100,100,100,100,200,200,200,200,300,300,300,300,400,400];
>
> Xa = [1,4,4,3,3,1]
> Ya = [100,100,400,400,300,300]
>
> Thanks,
>
> John

  Why don't we drop the hundreds? Suppose you have

 x = [1 2 3 4];
 y = [4 4 3 2];

What would be your xa and ya?

  As you can tell by this, I am still not certain about your shaping criterion.

Roger Stafford

Subject: Boundary of group of points

From: John

Date: 19 Mar, 2009 20:49:01

Message: 8 of 10

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gpuaf9$e8o$1@fred.mathworks.com>...
> "John" <johnsengenberger@hotmail.com> wrote in message <gpu8uh$q$1@fred.mathworks.com>...
> > "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gpu76a$snp$1@fred.mathworks.com>...
> > > "John" <johnsengenberger@hotmail.com> wrote in message <gpu68a$nat$1@fred.mathworks.com>...
> > > > I have a series of X,Y coordinates:
> > > >
> > > > X = [1,2,3,4,1,2,34,1,2,3,4];
> > > > Y = [100,100,100,100,200,200,200,200,300,300,400,400];
> > > >
> > > > I'm trying to determine which points lie on the edge of the "area" created by these points.
> > > > The results should look like:
> > > >
> > > > Xa = [1,2,3,4,4,3,2,1]
> > > > Ya = [100,100,100,100,400,400,300,300]
> > > >
> > > > The output will be a line plotted around the border of these points.
> > > > Any suggestions? I've been using the PATCH command to overlay the border, but I haven't been able to reduce my dataset down appropriately.
> > > > Thanks!
> > > > John
> > >
> > > If you hadn't included (2,300), I would have advised using 'convhull'. As things stand, you will have to define exactly what you mean by "the border of these points". What is your criterion for including (2,300) in the plot?
> > >
> > > Roger Stafford
> >
> > ------------------------------
> >
> > Roger,
> >
> > I'm trying to end up with a "city block" type out output - I'd like to have only vertical and horizontal lines... which means I might need to clarify that example. The inputs and outputs should be:
> >
> > X = [1,2,3,4,1,2,3,4,1,2,3,4,3,4];
> > Y = [100,100,100,100,200,200,200,200,300,300,300,300,400,400];
> >
> > Xa = [1,4,4,3,3,1]
> > Ya = [100,100,400,400,300,300]
> >
> > Thanks,
> >
> > John
>
> Why don't we drop the hundreds? Suppose you have
>
> x = [1 2 3 4];
> y = [4 4 3 2];
>
> What would be your xa and ya?
>
> As you can tell by this, I am still not certain about your shaping criterion.
>
> Roger Stafford
------------------------------
I'm looking to capture "blocks" - all the data I have currently plotted is in equal-sized rectangles, which I display using the PATCH command. My plot looks sort of like an Excel spreadsheet, with each cell having a different color. Each "cell" has certain data associated with it, and I'm trying to plot the path between two sets of data.

It should look like a border of the "cells" that meet the data criteria.

To address your x and y above, the border I'm envisioning would go through these points:

xa = [1 4 2 1]
ya = [4 2 4 4]

Thanks!

Subject: Boundary of group of points

From: us

Date: 19 Mar, 2009 22:00:07

Message: 9 of 10

"John"
> I'm looking to capture "blocks" - all the data I have currently plotted is in equal-sized rectangles, which I display using the PATCH command. My plot looks sort of like an Excel spreadsheet, with each cell having a different color. Each "cell" has certain data associated with it, and I'm trying to plot the path between two sets of data...

this is a bit confusing...
another try at a possible solution

% the data
     x=[10,20,30,40,10,20,30,10,20,30,40,30,40];
     y=[100,100,100,100,200,200,200,300,300,300,300,400,400];
% the engine
% - enumerate data
     [xu,xi,xi]=unique(x);
     [yu,yi,yi]=unique(y);
     xy=sortrows([yi(:),xi(:)]); % <- note: swap x/y for image-like display...
     b=flipud(accumarray(xy,xy(:,1),[max(yi),max(xi)]));
% the result
     imagesc(b);
     colormap(jet(max(yi)+1));
     colorbar;
     set(gca,'xtick',1:max(xi),'xticklabel',xu);
     set(gca,'ytick',1:max(xi),'yticklabel',yu);
     disp(b);
%{
     0 0 4 4
     3 3 3 3
     2 2 2 0
     1 1 1 1
%}

us

Subject: Boundary of group of points

From: us

Date: 19 Mar, 2009 22:12:02

Message: 10 of 10

"us"
> another try at a possible solution
> set(gca,'ytick',1:max(xi),'yticklabel',yu);

should be change to

% the data
     x=[10,20,30,40,10,20,30,10,20,30,40,30,40];
     y=[100,100,100,100,200,200,200,300,300,300,300,400,400];
% the engine
% - enumerate data
     [xu,xi,xi]=unique(x);
     [yu,yi,yi]=unique(y);
     xy=sortrows([yi(:),xi(:)]); % <- note: swap x/y for image-like display...
     b=flipud(accumarray(xy,xy(:,1),[max(yi),max(xi)]));
% the result
     imagesc(b);
     colormap(jet(max(yi)+1));
     colorbar;
     set(gca,'xtick',1:max(xi),'xticklabel',xu);
     set(gca,'ytick',1:max(xi),'yticklabel',yu(end:-1:1)); % <- CHANGE!
     disp(b);
%{
     0 0 4 4
     3 3 3 3
     2 2 2 0
     1 1 1 1
%}

us

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us