Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!w5g2000vbp.googlegroups.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: lsqcurvefit-initial guess better than fitting
Date: Sat, 21 Apr 2012 03:29:19 -0700 (PDT)
Organization: http://groups.google.com
Lines: 59
Message-ID: <a4fcc76b-acfb-41ce-914c-a0e5cdea1ae6@w5g2000vbp.googlegroups.com>
References: <jmqv7a$sg0$1@newscl01ah.mathworks.com> <jmr368$e41$1@newscl01ah.mathworks.com>
 <16668383-934e-4e45-a1be-d2585d5666f6@21g2000vbh.googlegroups.com> <jmrt6s$4hl$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 212.29.41.30
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1335004246 26227 127.0.0.1 (21 Apr 2012 10:30:46 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 21 Apr 2012 10:30:46 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: w5g2000vbp.googlegroups.com; posting-host=212.29.41.30; posting-account=X3eThQoAAACh5vOSip_rNRzKAq7k0jPW
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.22)
 Gecko/20110902 Firefox/3.6.22,gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:765400

On 20 Apr., 16:52, "HAN ZHOU" <repeatcl...@gmail.com> wrote:
> Hi Torsten!
>
> I tried to fit with 2 coeff as you told me today.
> However after the fitting, the resulting X will remain the same with my X0
>
> here is my function
> %%%%%%%%%%%%%%%%%%%
> function   f = myfun(X,Input)
>         t = Input{1};
>         deltax = Input{2};
>
>         f=0;
>                 for k=1:100
>                     inc = -X(1)*deltax*exp(-k^2*X(2)*t);
>                     f = f + inc;
>                 end
>     end
> %%%%%%%%%%%%%%%%%%%%
>
> And in another script I do the fitting
> %%%%%%%%%%%%%%%%%%%%
> [X,resnorm] = lsqcurvefit(@myfun,[3e-4 0.5e-5],Input,ydata,[0 0],[4e-4 3e-3])
> %%%%%%%%%%%%%%%%%%%%
>
> I get the initial value of X1 X2 by using cftool to fit with only 1 term, i.e.
> y = -d1*exp(-d2*t)
>
> Thank you so much for everything !!!
> Han
>
> Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <16668383-934e-4e45-a1be-d2585d566...@21g2000vbh.googlegroups.com>...
> > On 20 Apr., 09:28, "HAN ZHOU" <repeatcl...@gmail.com> wrote:
> > > Thanks so much!!!
> > > I will try your method and use upper/lower bound and see!!!
> > > Sorry I made a mistake in typing the last message, is actually
> > > myfun(X,t) = - X(1)*X(2)*sum of [exp(-i^2*X(2)*t)]
>
> > Then use
> > myfun(X,t) = -X(1)*sum of [exp(-n^2*X(2)*t]
> > and restrict X(2) to be positive.
>
> > Best wishes
> > Torsten.

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.