Newsgroups: comp.soft-sys.matlab
Subject: Re: Help with 2d or 3d data... (plane fit/lsplane.m)
Date: 21 Jun 2005 07:35:58 -0700
Lines: 41
Message-ID: <>
References: <d98d4i$7ao$>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: 1119364564 11522 (21 Jun 2005 14:36:04 GMT)
NNTP-Posting-Date: Tue, 21 Jun 2005 14:36:04 +0000 (UTC)
User-Agent: G2/0.2
Injection-Info:; posting-host=;
Xref: comp.soft-sys.matlab:285888

Allen schrieb:
> Hi everyone,
> I'm extremely new to matlab, so I'm very sorry if I'm missing some
> simple things... I've been trying to learn as much as possible... I need
> some help thinking about this current problem.
> I have height data taken from an AFM (atomic force microscope), each z
> height (nanometers) is taken at some x,y position (also in nanometers).
>   Currently I have imported the z array (256x256 double), and have also
> created an x and y array(s) corresponding to the positions along x and y
> of each point.  The data can be specified in 3d, in that it has a
> position in x, y, and z.  I would like to plane-fit the data with say,
> the lsplane.m file of I.M. Smith (included below for those who don't
> have it from the repository).  [or other plane-fitting routine you may
> suggest]
> I have some confusion about my data and the array required for
> lsplane.m.  Here's the input array information (quoting):  "Array [x y
> z] where x=vector of x-coords, y=vector of y-coords, z=vector of z
> coords, Dimension mx3."
> Now, how are my X, Y, Z matrices related to the array Lsplane.m is
> requesting?  I can't seem to merge the data together into a 3d array.
> [in a spread sheet, the x,y would simply be the index for the z data...
> x's size of course is 1x256 (so is Y, but I can transpose it), and Z's
> size is 256x256.


I assume the routine takes only triples of x,y,z data (actual space
coordinates). So if your z data is 2d, just generate appropriate x and
y array that are the same size as z. Look for meshgrid in the help.
Then you have as much x and y indices as you need for your z data.
Meshgrid simply repeats the x and y values as often as needed for the z
data. When reshaping x,y, and z to 256*256 x 1 vectors the routine
might work.

Hope I understood your problem,