Thread Subject: Building a 3D surface by giving coordinates (in a struct)

Subject: Building a 3D surface by giving coordinates (in a struct)

From: Daniel Drori

Date: 23 Jan, 2009 06:55:04

Message: 1 of 5

Hey there!!

I'm trying to build a 3D surface.
I used a struct to build my data-base witch includes 3 fields "x", "y", "z".
Now, after my bata base is built and ready and have all the coordinates I collected, I want, simply, to show all the 3-coordinates-points and connect them with a curvey surface.

Can anyone please help me out with it?
1) How to release the coordinates from the struct?
2) How to use those coordinates for building the surface?

Thanx alot,
Daniel.

Subject: Building a 3D surface by giving coordinates (in a struct)

From: Daniel Drori

Date: 23 Jan, 2009 09:12:02

Message: 2 of 5

"Daniel Drori" <dandul_d@yahoo.com> wrote in message <glbpk8$ig7$1@fred.mathworks.com>...
> Hey there!!
>
> I'm trying to build a 3D surface.
> I used a struct to build my data-base witch includes 3 fields "x", "y", "z".
> Now, after my bata base is built and ready and have all the coordinates I collected, I want, simply, to show all the 3-coordinates-points and connect them with a curvey surface.
>
> Can anyone please help me out with it?
> 1) How to release the coordinates from the struct?
> 2) How to use those coordinates for building the surface?
>
> Thanx alot,
> Daniel.

Please help...

Subject: Building a 3D surface by giving coordinates (in a struct)

From: David Doria

Date: 30 Jan, 2009 17:05:04

Message: 3 of 5

[X,Y] = meshgrid(x,y);
Z = griddata(x,y,z, X, Y);
figure;
surf(X,Y,Z);

Who knows why they don't provide a function to do this...?

Hope that helps!
Dave

Subject: Building a 3D surface by giving coordinates (in a struct)

From: us

Date: 30 Jan, 2009 18:26:01

Message: 4 of 5

"David Doria"
> [X,Y] = meshgrid(x,y);
> Z = griddata(x,y,z, X, Y);
> figure;
> surf(X,Y,Z);
> Who knows why they don't provide a function to do this...

simply to give CSSMers something to do for the rest of their lives...

:-)
us

Subject: Building a 3D surface by giving coordinates (in a struct)

From: Daniel Drori

Date: 4 Feb, 2009 21:47:01

Message: 5 of 5

"us " <us@neurol.unizh.ch> wrote in message <glvgnp$3h0$1@fred.mathworks.com>...
> "David Doria"
> > [X,Y] = meshgrid(x,y);
> > Z = griddata(x,y,z, X, Y);
> > figure;
> > surf(X,Y,Z);
> > Who knows why they don't provide a function to do this...
>
> simply to give CSSMers something to do for the rest of their lives...
>
> :-)
> us


Hey there!!

I'm trying to build a 3d surface from several samples of x,y,z that i took from the original picture. the x,y are presnting the position by pixels, and the 'z' is the distance from the camera to that spot.

I'm reading the data from a file into 3 vectors (x,y,z) and trying to build 3 matrices (XI,YI,ZI) with the code I use bellow:

tx = 1:1:PicSize(1);
ty = 1:1:PicSize(2);

[XI,YI] = meshgrid(tx,ty);
ZI = griddata(x,y,z,XI,YI,'cubic');

surf(XI,YI,ZI);
mesh(XI,YI,ZI), hold on;
plot3(x,y,z,'o'), hold off

As output I get a graph, but that graph is not similar at all to the picture that I took the samples from. The data that I use is fully correct.

The pixels' position (x,y) that I get from the picture is after using the method in matlab:
datacursormode on
I think this function might gives me wrong data, because the 0,0 position starts from the upper left corner and not from the bottom as I thought it should be.
When I show the graph using surf(XI,YI,ZI); the 0,0 position is at the bottom.

Dose anyone know how can I solve this problem?

Thanks in advance.
Daniel Drori.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
bsurface connec... B.M.E Guo 15 Apr, 2009 11:23:29
griddata Daniel Drori 4 Feb, 2009 16:50:08
picture Daniel Drori 4 Feb, 2009 16:50:08
meshgrid Daniel Drori 4 Feb, 2009 16:50:08
datacursormode Daniel Drori 4 Feb, 2009 16:50:08
plot Daniel Drori 4 Feb, 2009 16:50:08
daniel Daniel Drori 4 Feb, 2009 16:50:08
drori Daniel Drori 4 Feb, 2009 16:50:08
surf Daniel Drori 4 Feb, 2009 16:50:08
mesh Daniel Drori 4 Feb, 2009 16:50:08
daniel drori Daniel Drori 23 Jan, 2009 02:24:51
x y z Daniel Drori 23 Jan, 2009 01:55:16
points Daniel Drori 23 Jan, 2009 01:55:16
coordinates Daniel Drori 23 Jan, 2009 01:55:16
3d surface Daniel Drori 23 Jan, 2009 01:55:16
giving coordinates Daniel Drori 23 Jan, 2009 01:55:16
struct Daniel Drori 23 Jan, 2009 01:55:15
surface Daniel Drori 23 Jan, 2009 01:55:15
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com