Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Curve fitting a 3D data set
Date: Thu, 15 Nov 2007 23:22:14 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 73
Message-ID: <fhikb6$r26$1@fred.mathworks.com>
References: <eef3579.-1@webx.raydaftYaTP> <cnjb5n$guv$1@news-int2.gatech.edu> <eef3579.2@webx.raydaftYaTP> <cnl2d2$cd5$1@fb04373.mathematik.tu-darmstadt.de> <cnl63d$bbt$1@news-int2.gatech.edu>
Reply-To: <HIDDEN>
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 1195168934 27718 172.30.248.35 (15 Nov 2007 23:22:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Nov 2007 23:22:14 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1117672
Xref: news.mathworks.com comp.soft-sys.matlab:437827



I've been trying to implement this method but I'm having
some problems.  I think I've written the function I'm
fitting to incorrectly.  I'm trying to do a global fit to a
data set that I have previously fit by non-globally.  This
is the error I get:

??? Error using ==> optim/private/lsqncommon at 131
Function value and YDATA sizes are incommensurate.

my function call is as such:
[x,resnorm,residual,exitflag,output,lambda,jacobian] =
lsqcurvefit(@globfun,x_init,Time_Tot',cleanex.data',lb,ub);

where @globfun is:
function F = globfun(xy,xydata)
F(1) =
xy(2)*(exp(xy(1)*xydata(1))-exp(-(xy(2)+xy(3))*xydata(1)))/(xy(2)+xy(3)-xy(1))
F(2) =
xy(4)*(exp(xy(1)*xydata(2))-exp(-(xy(4)+xy(5))*xydata(2)))/(xy(4)+xy(5)-xy(1))
F(3) =
xy(6)*(exp(xy(1)*xydata(3))-exp(-(xy(6)+xy(7))*xydata(3)))/(xy(6)+xy(7)-xy(1))
...

Time_Tot and cleanex.data are both m by n matrices
Before my error I get the following cycle:
F = 0.7506
F = 0.7506    0.0248
F = 0.7506    0.0248    0.3464
...

Where in the non-global (2D) case I would get a series of
column vectors that would approach cleanex.data(:,i) with
each cycle.  Why is it iterating through the individual
functions instead of fitting the system?


"Teddy Hsung" <gtg101p@mail.gatech.edu> wrote in message
<cnl63d$bbt$1@news-int2.gatech.edu>...
> I guess his problem can be formulated like this:
> 
> z1 = f(x1, y1, p1,p2...)
> z2 = f(x2, y2, p1,p2...)
> .
> .
> .
> zn = f(xn, yn, p1,p2...)
> 
> where f is a known form of function. p1,p2... are the
parameters that he 
> wants to estimate.
> 
> \ (slash) function probably won't work because his
function is highly 
> possible a nonlinear function.
> 
> p=LSQCURVEFIT(f,p0,XYDATA,ZDATA) should be able to solve
this problem.
> 
> where, p is a vector [p1, p2..]', p0 is initial guess of p.
> 
> XYDATA is a matrix [x1,y1
>                     x2,y2
>                     .....
>                     xn,yn]
> 
> ZDATA is a vector  [z1, z2...zn]'
> 
> Please let us know how it works
> 
> Rentian
> 
>