From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Curve fitting problem
Date: Tue, 16 Dec 2008 20:04:02 +0000 (UTC)
Organization: Tufts University
Lines: 11
Message-ID: <gi91ji$b7a$>
References: <gi6gvi$jlc$> <gi7tie$jau$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1229457842 11498 (16 Dec 2008 20:04:02 GMT)
NNTP-Posting-Date: Tue, 16 Dec 2008 20:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 967938
Xref: comp.soft-sys.matlab:507377

"Roger Stafford" <> wrote in message <gi7tie$jau$>...
> "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

Thank you for the suggestion. I can see that the Lorentzian is linear in the a and vshift terms, and I see that this reduces the number of parameters that fminsearch has to deal with. So if the function of Lorentzians were called L(x), and each lorentzian in the sum were l(x), then L(x)=a1*l1(x)+a2*l2(x)+a3*l3(x)+vshift. What I am unclear on is how to rewrite the function to always achieve the minimum of the a and vshift values. I can see where it should be the solution to a system of linear equations that would automatically minimize the a and vshift values, but I guess I am not seeing how I can get this into a form that I can pass to fminsearch using only the remaining 6 parameters. I apologize for being so obtuse, and I thank you for all of your help.