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:
Plotting a surface with 'holes'

Subject: Plotting a surface with 'holes'

From: Ray

Date: 28 Apr, 2009 03:50:56

Message: 1 of 8

I have the x-y-z coordinates of a set of points which I'd like to plot
as a 3-D surface. At some coordinates, the points do not exist. The
plotted surface should therefore show gaps or 'holes' in areas where
points are missing. I've tried the 'surf' command but that doesn't
render the desired surface. I found that 'surf' fits a nice smooth
surface over the points while interpolating between the points, hence
filling in those 'holes'.
Is there a another Matlab command or any way in Matlab to get the plot
I'm after ? Thanks a lot for your help.

Ray

Subject: Plotting a surface with 'holes'

From: Steven Lord

Date: 28 Apr, 2009 04:16:18

Message: 2 of 8


"Ray" <rbenbernou@yahoo.com> wrote in message
news:4b1c137e-8df2-4f78-9e96-dc4e922d02df@p6g2000pre.googlegroups.com...
>I have the x-y-z coordinates of a set of points which I'd like to plot
> as a 3-D surface. At some coordinates, the points do not exist. The
> plotted surface should therefore show gaps or 'holes' in areas where
> points are missing. I've tried the 'surf' command but that doesn't
> render the desired surface. I found that 'surf' fits a nice smooth
> surface over the points while interpolating between the points, hence
> filling in those 'holes'.
> Is there a another Matlab command or any way in Matlab to get the plot
> I'm after ? Thanks a lot for your help.
>
> Ray

Put a NaN in your data where you want the hole to be placed.

--
Steve Lord
slord@mathworks.com

Subject: Plotting a surface with 'holes'

From: Gustavo Morales

Date: 28 Apr, 2009 04:24:01

Message: 3 of 8

Ray:

Hi !
I'm not sure if I can help you, but try with the folowing commands:

X = [1, 3, 5]; Y = [1, 2, 6]; Z = [1, 3, 4]; % Defining 3 points
tcolor = [1 1 1]; % Defining color
patch(X,Y,Z,tcolor); % Graph of the poligon with X Y Z vertexs
grid on; view(3) % Fixing the final look

Subject: Plotting a surface with 'holes'

From: Gustavo Morales

Date: 28 Apr, 2009 04:33:02

Message: 4 of 8

The solution with NaN's is the correct...!

I'm practicing my english and learning Matlab..! What more can I ask? :-D

Subject: Plotting a surface with 'holes'

From: Ray

Date: 29 Apr, 2009 04:24:47

Message: 5 of 8

On Apr 28, 7:50 am, Ray <rbenber...@yahoo.com> wrote:
> I have the x-y-z coordinates of a set of points which I'd like to plot
> as a 3-D surface. At some coordinates, the points do not exist. The
> plotted surface should therefore show gaps or 'holes' in areas where
> points are missing. I've tried the 'surf' command but that doesn't
> render the desired surface. I found that 'surf' fits a nice smooth
> surface over the points while interpolating between the points, hence
> filling in those 'holes'.
> Is there a another Matlab command or any way in Matlab to get the plot
> I'm after ? Thanks a lot for your help.
>
> Ray


Thank you guys for your help. NaN works beautifully.

Subject: Plotting a surface with 'holes'

From: Adam

Date: 21 May, 2010 17:15:29

Message: 6 of 8

Ray <rbenbernou@yahoo.com> wrote in message <14c1f967-6172-4e2d-9772-855a7f2c48ba@b7g2000pre.googlegroups.com>...
> On Apr 28, 7:50 am, Ray <rbenber...@yahoo.com> wrote:
> > I have the x-y-z coordinates of a set of points which I'd like to plot
> > as a 3-D surface. At some coordinates, the points do not exist. The
> > plotted surface should therefore show gaps or 'holes' in areas where
> > points are missing. I've tried the 'surf' command but that doesn't
> > render the desired surface. I found that 'surf' fits a nice smooth
> > surface over the points while interpolating between the points, hence
> > filling in those 'holes'.
> > Is there a another Matlab command or any way in Matlab to get the plot
> > I'm after ? Thanks a lot for your help.
> >
> > Ray
>
>
> Thank you guys for your help. NaN works beautifully.


Hi, I am doing the same thing myself using NaN to make holes in my surf plot. But rather than have these undefined regions white with grid lines, I would like it to be grey. I thought I could do it in illustrator by putting a grey square behind the surf plot, but of course this won't work as the color map doesn't de-group that way...

Is there an easy solution i'm missing here??

Adam

Subject: Plotting a surface with 'holes'

From: Adam

Date: 21 May, 2010 17:16:21

Message: 7 of 8

Ray <rbenbernou@yahoo.com> wrote in message <14c1f967-6172-4e2d-9772-855a7f2c48ba@b7g2000pre.googlegroups.com>...
> On Apr 28, 7:50 am, Ray <rbenber...@yahoo.com> wrote:
> > I have the x-y-z coordinates of a set of points which I'd like to plot
> > as a 3-D surface. At some coordinates, the points do not exist. The
> > plotted surface should therefore show gaps or 'holes' in areas where
> > points are missing. I've tried the 'surf' command but that doesn't
> > render the desired surface. I found that 'surf' fits a nice smooth
> > surface over the points while interpolating between the points, hence
> > filling in those 'holes'.
> > Is there a another Matlab command or any way in Matlab to get the plot
> > I'm after ? Thanks a lot for your help.
> >
> > Ray
>
>
> Thank you guys for your help. NaN works beautifully.


Hi, I am doing the same thing myself using NaN to make holes in my surf plot. But rather than have these undefined regions white with grid lines, I would like it to be grey. I thought I could do it in illustrator by putting a grey square behind the surf plot, but of course this won't work as the color map doesn't de-group that way...

Is there an easy solution i'm missing here??

Adam

Subject: Plotting a surface with 'holes'

From: elvis asong ZILEFAC

Date: 14 Apr, 2013 06:34:08

Message: 8 of 8

Ray <rbenbernou@yahoo.com> wrote in message <4b1c137e-8df2-4f78-9e96-dc4e922d02df@p6g2000pre.googlegroups.com>...
> I have the x-y-z coordinates of a set of points which I'd like to plot
> as a 3-D surface. At some coordinates, the points do not exist. The
> plotted surface should therefore show gaps or 'holes' in areas where
> points are missing. I've tried the 'surf' command but that doesn't
> render the desired surface. I found that 'surf' fits a nice smooth
> surface over the points while interpolating between the points, hence
> filling in those 'holes'.
> Is there a another Matlab command or any way in Matlab to get the plot
> I'm after ? Thanks a lot for your help.
>
> Ray

Hello guys,

I have a similar problem as Ray. I have XY coordinates. I have gridded my data using Triscatterinterp...The resulting Z values contain NaNs. However, I would appreciate if you let me know how to contourf(X,Y,Z) without errors. That is, I would like to interpolate values at points having NaNs.

Thanks so much for your useful reply.
Asong.

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