Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Curve fitting problem
Date: Tue, 16 Dec 2008 09:49:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <gi7tie$jau$1@fred.mathworks.com>
References: <gi6gvi$jlc$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1229420942 19806 172.30.248.37 (16 Dec 2008 09:49:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Dec 2008 09:49:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:507259

"Tazmusica " <tazmusica2@deletethis.gmail.com> wrote in message <gi6gvi$jlc$1@fred.mathworks.com>...
> I am trying to fit several data sets to a sum of Lorentzians. I have written code that uses fminsearch. For data that is a sum of two Lorentzians, it
> seems to work fine. When I try and fit data that is a sum of 3 or more Lorentzians, it seems to have difficulty. ........

  Here's one suggestion that might help.  You can, in effect, reduce the total number of parameters you are dealing with by writing your function to be minimized in such a way as to automatically adjust the a-parameters and vshift to achieve a minimum square.  Your function of Lorenzians is linear in these four parameters and for any given value of the other six, a minimum with respect to these four can always be achieved without iteration.  It is simply the solution to a set of four linear equations.  So your function can be rewritten to always achieve such a minimum and therefore would involve only the other six parameters to be handed to fminsearch for variation.  Six parameters is a whole lot easier for fminsearch to deal with than ten in terms of running into blind alleys or wandering around aimlessly.

Roger Stafford