Path: news.mathworks.com!not-for-mail
From: "Daniel Drori" <dandul_d@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Building a 3D surface by giving coordinates (in a struct)
Date: Wed, 4 Feb 2009 21:47:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 41
Message-ID: <gmd2cl$dsc$1@fred.mathworks.com>
References: <glbpk8$ig7$1@fred.mathworks.com> <glc1l2$ioi$1@fred.mathworks.com> <glvc00$f47$1@fred.mathworks.com> <glvgnp$3h0$1@fred.mathworks.com>
Reply-To: "Daniel Drori" <dandul_d@yahoo.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1233784021 14220 172.30.248.35 (4 Feb 2009 21:47:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Feb 2009 21:47:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1624174
Xref: news.mathworks.com comp.soft-sys.matlab:516159


"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.