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$>
References: <gi6gvi$jlc$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1229420942 19806 (16 Dec 2008 09:49:02 GMT)
NNTP-Posting-Date: Tue, 16 Dec 2008 09:49:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:507259

"Tazmusica " <> wrote in message <gi6gvi$jlc$>...
> 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