Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!w7g2000vbg.googlegroups.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: lsqcurvefit-initial guess better than fitting
Date: Sun, 22 Apr 2012 23:53:09 -0700 (PDT)
Organization: http://groups.google.com
Lines: 41
Message-ID: <08e78b93-2e28-48c2-907c-f5148411e8ae@w7g2000vbg.googlegroups.com>
References: <jmqv7a$sg0$1@newscl01ah.mathworks.com> <jmr368$e41$1@newscl01ah.mathworks.com>
 <a4fcc76b-acfb-41ce-914c-a0e5cdea1ae6@w5g2000vbp.googlegroups.com> <jn18h8$3ut$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 192.102.151.35
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1335163990 15877 127.0.0.1 (23 Apr 2012 06:53:10 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 23 Apr 2012 06:53:10 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: w7g2000vbg.googlegroups.com; posting-host=192.102.151.35; posting-account=X3eThQoAAACh5vOSip_rNRzKAq7k0jPW
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
 Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR
 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:765552

On 22 Apr., 17:36, "Han Zhou" <repeatcl...@gmail.com> wrote:
> Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <a4fcc76b-acfb-41ce-914c-a0e5cdea1...@w5g2000vbp.googlegroups.com>...
> > 1. Your call to lsqcurvefit and the interpretation of the arguments in
> > myfun are wrong.
> > 2. At the moment, myfun returns the model y-data for only _one_ data
> > point to lsqcurvefit.
>
> > Look at the example problems for lsqcurvefit in the documentation.
>
> > Best wishes
> > Torsten.
>
> Dear Torsten,
>
> I read the example many times but I could not really see why myfun will return only one model y-data. Could you give me some indication?
> Is it because the 2 Input cell have different length?
> The tricky point is that in myfun there is a problem-dependent parameter deltax, so I could not use only one input vector - xdata.
>
> Danke Schoen und bis bald!!!
>
> Han

%%%%%%%%%%%%%%%%%%%
function   f = myfun(x,xdata,deltax)
        f=0;
        for k=1:100
           f = f -X(1)*deltax.*exp(-k^2*X(2)*xdata);
        end
    end
%%%%%%%%%%%%%%%%%%%%


And in another script I do the fitting
%%%%%%%%%%%%%%%%%%%%
[X,resnorm] = lsqcurvefit(@(x,xdata)myfun(x,xdata,deltax),
[3e-4;0.5e-5],xdata,ydata,[0;0],[4e-4;3e-3])
%%%%%%%%%%%%%%%%%%%%

Best wishes
Torsten.