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:
How to plot data on arbitrary mesh?

Subject: How to plot data on arbitrary mesh?

From: Sebastian Gatzka

Date: 10 Feb, 2011 12:29:04

Message: 1 of 7

Hello World.

I want to plot data on an arbitrary mesh.
I thought about using contourf or something similar.
But I am not sure how to handle the matrices which contain the coordinates and data correctly.

These are the matrices I have present:

- One matrix (1950x20) containing all x-positions of the mesh points
- One matrix (1950x20) containing all y-positions of the mesh points
- One matrix (1950x20) containing scalar values corresponding to the mesh points.

So the mesh contains of 950x20 2-dimensional points and data.
What do I have to do to plot this?!

Thank you so far.
sega

Subject: How to plot data on arbitrary mesh?

From: kinor

Date: 10 Feb, 2011 15:24:03

Message: 2 of 7

"Sebastian Gatzka" <sebastian.gatzka.NOSPAM@stud.tu-darmstadt.de> wrote in message <ij0lmg$g4t$1@fred.mathworks.com>...
> Hello World.
>
> I want to plot data on an arbitrary mesh.
> I thought about using contourf or something similar.
> But I am not sure how to handle the matrices which contain the coordinates and data correctly.
>
> These are the matrices I have present:
>
> - One matrix (1950x20) containing all x-positions of the mesh points
> - One matrix (1950x20) containing all y-positions of the mesh points
> - One matrix (1950x20) containing scalar values corresponding to the mesh points.
>
> So the mesh contains of 950x20 2-dimensional points and data.
> What do I have to do to plot this?!
>
> Thank you so far.
> sega

Hi Sebastian,

this is not the world...

Do I get it right, you have 1950x20 points in 3D and you want to plot them?

help plot3

hth
kinor

Subject: How to plot data on arbitrary mesh?

From: Sebastian Gatzka

Date: 10 Feb, 2011 16:16:04

Message: 3 of 7

"kinor" wrote in message <ij0vuj$nur$1@fred.mathworks.com>...

>
> Hi Sebastian,
>
> this is not the world...
>
> Do I get it right, you have 1950x20 points in 3D and you want to plot them?
>
> help plot3
>
> hth
> kinor

I have 1950x20 points in 2D (x,y) and want to plot a scalar field corresponding to these points.

Subject: How to plot data on arbitrary mesh?

From: kinor

Date: 10 Feb, 2011 16:27:04

Message: 4 of 7

"Sebastian Gatzka" <sebastian.gatzka.NOSPAM@stud.tu-darmstadt.de> wrote in message <ij1303$bcv$1@fred.mathworks.com>...
> "kinor" wrote in message <ij0vuj$nur$1@fred.mathworks.com>...
>
> >
> > Hi Sebastian,
> >
> > this is not the world...
> >
> > Do I get it right, you have 1950x20 points in 3D and you want to plot them?
> >
> > help plot3
> >
> > hth
> > kinor
>
> I have 1950x20 points in 2D (x,y) and want to plot a scalar field corresponding to these points.

ok, if you plot your points in the xy-plane you have a 2D plot of your points:
plot(x,y)
Adding the scalar field gives you the 3rd dimension of your plot:
plot3(x, y, scalar_field)

Subject: How to plot data on arbitrary mesh?

From: Sebastian Gatzka

Date: 10 Feb, 2011 17:09:04

Message: 5 of 7

"kinor" wrote in message <ij13ko$n27$1@fred.mathworks.com>...
>
> ok, if you plot your points in the xy-plane you have a 2D plot of your points:
> plot(x,y)
> Adding the scalar field gives you the 3rd dimension of your plot:
> plot3(x, y, scalar_field)

Hm, this results in some really strange line plot.

What I want is something like this:
http://img821.imageshack.us/i/scalarfield2.png/

There you can see the mesh and the the colored scalar field.

Does this make it more clear what I want to achieve?

Subject: How to plot data on arbitrary mesh?

From: kinor

Date: 10 Feb, 2011 18:40:07

Message: 6 of 7

"Sebastian Gatzka" <sebastian.gatzka.NOSPAM@stud.tu-darmstadt.de> wrote in message <ij163g$40h$1@fred.mathworks.com>...
> "kinor" wrote in message <ij13ko$n27$1@fred.mathworks.com>...
> >
> > ok, if you plot your points in the xy-plane you have a 2D plot of your points:
> > plot(x,y)
> > Adding the scalar field gives you the 3rd dimension of your plot:
> > plot3(x, y, scalar_field)
>
> Hm, this results in some really strange line plot.
>
> What I want is something like this:
> http://img821.imageshack.us/i/scalarfield2.png/
>
> There you can see the mesh and the the colored scalar field.
>
> Does this make it more clear what I want to achieve?

sorry

plot3(x, y, scalar_field, 'kx')

will give you the point cloud of your data

tri = delaunay(x,y);
trisurf(tri,x,y,scalar_field);

will do the job

hth
kinor

ps:
if you want to have neighbouring points connected and your x and y positions are sorted (not really an arbitrary mesh) you can use
surfx, y, scalar_field)

Subject: How to plot data on arbitrary mesh?

From: Sebastian Gatzka

Date: 10 Feb, 2011 19:22:04

Message: 7 of 7

"kinor" wrote in message <ij1be7$i2j$1@fred.mathworks.com>...

>
> sorry
>
> plot3(x, y, scalar_field, 'kx')
>
> will give you the point cloud of your data
>
> tri = delaunay(x,y);
> trisurf(tri,x,y,scalar_field);
>
> will do the job
>
> hth
> kinor
>
> ps:
> if you want to have neighbouring points connected and your x and y positions are sorted (not really an arbitrary mesh) you can use
> surfx, y, scalar_field)

Great!
Finally what I want!!!
Thank you!

Tags for this Thread

No tags are associated with 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