From: Frank on
Hi all!

I need your help. I would like to create a code that allows me to fit a vector of data with a custom fit function (let's say a lorentzian curve to make an example). In that case my fitting parameters would be the position, the height and the half-width of the peak.

How may I write such a function in order to fit my vector of data? I would also like to put some constranits on the values for the different parameters, like you can do in the graphical fitting toolbox, where you can specify e.g. the maximum linewidth for the peak and so on.

Any help would be very appreciated!

Thanks in advance

Frank
From: James Allison on
Perhaps lsqcurvefit would work for you. It allows bounds on function
parameters.

-James

Frank wrote:
> Hi all!
>
> I need your help. I would like to create a code that allows me to fit a
> vector of data with a custom fit function (let's say a lorentzian curve
> to make an example). In that case my fitting parameters would be the
> position, the height and the half-width of the peak.
>
> How may I write such a function in order to fit my vector of data? I
> would also like to put some constranits on the values for the different
> parameters, like you can do in the graphical fitting toolbox, where you
> can specify e.g. the maximum linewidth for the peak and so on.
>
> Any help would be very appreciated!
>
> Thanks in advance
>
> Frank
From: Frederic Moisy on
Dear Frank,
Try Ezyfit:
http://www.mathworks.com/matlabcentral/fileexchange/10176-ezyfit-2-30
examples to fit gaussians can be find here:
http://www.mathworks.com/matlabcentral/fx_files/10176/3/content/ezyfit/demo/html/efdemo.html
(Unfortunately constrained fits are not available yet in this toolbox)
F.



"Frank " <francesco.manni01(a)fastwebnet.it> wrote in message <hofq1k$ss6$1(a)fred.mathworks.com>...
> Hi all!
>
> I need your help. I would like to create a code that allows me to fit a vector of data with a custom fit function (let's say a lorentzian curve to make an example). In that case my fitting parameters would be the position, the height and the half-width of the peak.
>
> How may I write such a function in order to fit my vector of data? I would also like to put some constranits on the values for the different parameters, like you can do in the graphical fitting toolbox, where you can specify e.g. the maximum linewidth for the peak and so on.
>
> Any help would be very appreciated!
>
> Thanks in advance
>
> Frank