Code covered by the BSD License  

Highlights from
lorentzian fit

4.71429

4.7 | 7 ratings Rate this file 50 Downloads (last 30 days) File Size: 2.08 KB File ID: #13648
image thumbnail

lorentzian fit

by Yohanan Sivan

 

13 Jan 2007 (Updated 15 Jan 2007)

In the attached file example i use "nlinfit", which can fit any kind of function that you want. the

| Watch this File

File Information
Description

On the gaussian fit i used "polyfit" which gives you en absolut one solution, but have some problems fitting non-linear model.

In the attached file example i use "nlinfit", which can fit any kind of function that you want. the problem is that you need to give here a starting point.

"main.m" include the example code to use nlinfit.

"data.txt" is data (x,y) that needed to be fitted.

"fun.m" is the function to be fitted, in you case it's lorentzian.

MATLAB release MATLAB 7 (R14)
Other requirements the function "nlinfit"
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
09 May 2007 victor yashunsky  
30 Jul 2007 Oliver Chen

This was very helpful in my understanding of the gaussian fit. thank you

10 Feb 2008 Arye Lerner

Exellent. Thanks.

01 Sep 2008 ander zornoza

when I introduce my data an error ocurs:

??? Error using ==> nlinfit at 129
MODELFUN should return a vector of fitted values the same length as Y.

Error in ==> main at 56
vEnd=nlinfit(x,yOrig,@fun,vStart);

Please I need Help

12 Mar 2009 Patrick Ledingham

Excellent. Works really well. Thanks

05 May 2009 Chad Bircher

When I attempt to use these programs I get the following error
Undefined function or method 'nlinfit' for input arguments of type
'function_handle'.
 Do you know why MatLab would respond to the programs this way?

19 May 2009 Eric Zilli

Not terribly useful. This is an example, not a fitting function and it is not very well written. It is, however, slightly more useful than the poor documentation on the function nlinfit.

The code does not seem to be performing a fit to a Lorentzian, though, as the function fun.m (why not give it a more useful name?) is multiplied by 2 for some reason and the (x-x_0) term in the denominator is multiplied by 4 for some reason. Possibly this is a standard form in some field I have never come across, but this is certainly not the Lorentzian function I am interested in fitting. It is easy enough to fix, but worth pointing out to others who might use this.

05 Nov 2010 sohag khan

your code don't work to fit my data in Lorentzian. Can u please help?
here is my data

a=[-1000*1e3 -100*1e3 -10*1e3 -5*1e3 -1*1e3 0 1*1e3 5*1e3 10*1e3 100*1e3 1000*1e3];
b=[-110 -90 -80 -70 -60 0 -60 -70 -80 -90 -110];
data in b is in dB
can u plz help me to find the fit.
thanks

Reza

28 Jul 2011 guo

good

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Yohanan Sivan 22 Oct 2008 08:56:53
probability Yohanan Sivan 22 Oct 2008 08:56:53
lorentzian fit nlinfit polyfit Yohanan Sivan 22 Oct 2008 08:56:53
lorentzian fit nlinfit polyfit Manoj 22 Feb 2010 01:19:03
lorentzian fit nlinfit polyfit gal elhalel 30 Nov 2010 08:12:34
lorentzian fit nlinfit polyfit benjamin 01 Apr 2011 19:24:03
lorentzian fit nlinfit polyfit LI Yun 23 May 2011 09:25:15
lorentzian fit nlinfit polyfit tomi langer 01 Aug 2011 04:51:12

Contact us at files@mathworks.com