From: manfred <lerxt@cyberdude.com>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webx
Newsgroups: comp.soft-sys.matlab
Subject: Re: Curve fitting a 3D data set
Message-ID: <eef3579.11@webx.raydaftYaTP>
Date: Tue, 30 Nov 2004 06:40:23 -0500
References: <eef3579.-1@webx.raydaftYaTP> <eef3579.9@webx.raydaftYaTP> <eef3579.10@webx.raydaftYaTP>
Lines: 68
NNTP-Posting-Host: 194.105.121.177
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:244881



try the following:

%suppose my data is a 512x512 double array.

%first define a linear grid
x=linspace(-1,1,512);
[x,z]=meshgrid(x,x);
x=x(:);z=z(:);

A=[x.^2,z.^2,x,z,ones(length(x),1)];
C=data(:)'/A';
% C gives coefficients for 3D parabola

% data, corrected for parabola:
delta=data(:) - (C*A')';
datacorr=reshape(delta,512,512);

%do some plotting:
figure;imagesc(data-datacorr);

-Manfred.

Sanne Christensen wrote:
>
>
> Hi Paolo
>
> I've scipped using the lsqcurve with x, y, z - it just wouldn't
> work
> for me. Instead I'm using polyfit (I could also use lsqcurve) on x,
> y
> and x, z respectively so I get two curves in a 2D coordinate
> system.
> Then i project one of the curves onto the other and this way I get
> my
> final curve in a 3D coordinate system. I've heard that there are
> ways
> to do it in 3D in Matlab, but I have a deadline coming up and
> therefore I don't have time to figure out how to do it :)
>
> /Sanne
>
> Paolo Benetti wrote:
>>
>>
>> Sanne Christensen wrote:
>>>
>>>
>>> I'm pretty new in the Matlab-world. How do I make curve
> fitting
>> on
>>> a
>>> 3D data set (x, y, z)? Do I need a special toolbox for it?
>>>
>>> Thanx for your help :)
>>> Sanne
>>
>> Dear Sanne,
>> I think we're working on the same problem.
>> I got a set of 3D points in Cartesian coordinates and I want to
>> find
>> the equation of the paraboloid that describes these points. It
>> would
>> be an antenna. If I have some interesting news about it I'll
tell
>> you, hoping you'll do the same!
>>
>> Paolo