4.83951

4.8 | 84 ratings Rate this file 150 Downloads (last 30 days) File Size: 664.18 KB File ID: #10176
image thumbnail

EzyFit 2.40

by Frederic Moisy

 

27 Feb 2006 (Updated 29 Jul 2010)

A free curve fitting toolbox for Matlab

| Watch this File

File Information
Description

The Ezyfit toolbox for Matlab enables you to perform simple curve fitting of one-dimensional data using arbitrary (non linear) fitting functions.

EzyFit adds a new menu to your figure windows, which allows you to easily fit your data with predefined or user-defined fit equations, including selection of your data (outliers removing) using the ``Data Brushing'' tool (available since Matlab 7.6).

This toolbox also provides a set of command-line functions to perform curve fitting 'programmatically': you just have to type something like showfit('c+a/x^n') and EzyFit gives you the values for c, a and n and shows you the curve!

Visit http://www.fast.u-psud.fr/ezyfit/ for additional info.

Installation and system requirements

EzyFit needs Matlab 7.0 or higher. It has been tested under 7.0 to 7.10 (R2010a), but mainly under Windows XP. The command-line functions (e.g. ezfit, showfit...) work equally well on all systems. However graphical operations (e.g. showslope, getslope...) may not be fully stable, especially on non-Windows systems, and/or for recent Matlab releases.

1. Download and unzip the EzyFit Toolbox in a directory somewhere in your system. For instance, in a Windows XP installation, the directory My Documents/MATLAB/toolbox/ezyfit may be a good location. Do NOT install the toolbox in the Matlab directory itself (Program Files/Matlab directory in Windows). If you upgrade from an older version, first empty the previous directory.

2. From the menu 'File > Set Path', click on 'Add Folder' (NOT 'with subfolders') and select the ezyfit directory. Click on 'Save' and 'Close'.

3. Restart Matlab. From the Start button, select Toolboxes > EzyFit to check that the toolbox is correctly recognized by your system.

4. If you want to always have the Ezyfit menu in your figures, type efmenu install. This will create or update your 'startup.m' file in the directory /toolbox/local of your Matlab installation.

Note: If you upgrade Matlab and you want to use your previous Ezyfit installation, you just have to follow the steps 2-4.

Examples:

plotsample power % a power law
showfit c*x^n

plotsample hist % an histogram
f = ezfit('gauss'); % fits with a Gaussian
f % displays the values of the coefficients

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (98)
03 Mar 2006 Jack Chen

Looks like a great free toolbox for matlab. However, I'm getting the following error:

>> efmenu install
??? Error using ==> load
Unable to read MAT file d:\matlab\easyfit\userfit.mat

07 Mar 2006 Frederic Moisy

Dear Jack Chen,
This error does not occur with R14.
Some features of this toolbox (eg, nested functions) need R14. Sorry.

21 Mar 2006 John D'Errico

While I did not try out the menu interface, the command line interface was indeed easy to use. A splendid tool.

28 Sep 2006 Blair Greenan

Excellent toolbox for curve fitting. Any questions I had were quickly answered by the author.

06 Oct 2006 Dietrich Lueerssen

I do like this toolbox, and it works well for me. It is really useful that there are both a GUI and a programmatical access, well done.

I do have a suggestion for future versions: at the moment, parameters of the fit such as its color are hardcoded into a file (fitparam.m). It would be helpful to be able to control that programmatically, particularly if you want to show multiple fit curves for the same data set (e.g., to show that one fit is better than another one).

30 Oct 2006 Frederic Moisy

Dear D. Lueerssen, Thanks for your comment. The new version (2.10), submitted 30 oct 2006, now allows for specifying fit parameters programmatically. Example: showfit('a*x+b','fitcolor','red',...) - The author.

29 Mar 2007 Jonas Semoi  
30 Mar 2007 Ravi Prakash

Hi,
Its superb toolbox you ahve provided to Matlab users. I was struggling to fit a smooth curve for amplitude analysis of seismic data. This toolbox does it in fantastic way.
Thanks
Ravi

30 Mar 2007 Andrew Isaacs

Excellent work. Did what I needed (multiple power terms) when no-one else could - at least for free. Easy to install and work with, and great solutions.

13 Apr 2007 Matt Lopz

Excellent Utilty.

14 Apr 2007 atanas atanasov  
17 Apr 2007 Josiah Haswell

Fabulous

04 May 2007 MArta Castillo

Excellent

27 May 2007 david abks

Great - well done!!!!!!!!

05 Jun 2007 Andres Leal

Great software! I was able to do curve fits using custom equations that wouldn't be fitted with KaleidaGraph.

20 Jun 2007 D J

a nice tolbox...best alternative to matlab curve fitting toolbox which sadly doesnot come for student version of the software.

19 Jul 2007 Woody Schneider

Great, but it behaves sketchily on the Mac OS X Intel version...

24 Jul 2007 Gilles Bertrand

A great tool! Fill a gap in matlab functionalities. Good interface, good integration into matlab, merci Frederic M.!!

03 Nov 2007 Alex Liberzon

Very useful.

09 Nov 2007 Chintan Trivedi  
14 Nov 2007 andy yang

So splendid!

19 Nov 2007 Hauke Schramm  
03 Dec 2007 Mickael PARIS  
05 Dec 2007 Joe M  
03 Jan 2008 m la  
12 Jan 2008 Mark Dean

Thank you for a useful and well writtten program!
I was able to write a small program to easily choose whether to fix or vary some of the fit parameters. It would be useful if this was included as standard.

29 Jan 2008 A Rose

Perfect! Just what I needed to estimate parameters for over 500 chick growth curves.

05 Feb 2008 R B

Very good and powerful toolbox

19 Feb 2008 P. Sci  
02 Mar 2008 sri murthy

Great alternative to cftool...excellent

18 Apr 2008 K E

Very helpful and intuitive.

12 Jun 2008 Jason Ruth

Fantastic program, very straightforward and easy to use.

23 Jun 2008 Nirvikar Dashora

Please tell me how to Unistall the ezyfit toolbox from MATLAB.

27 Jun 2008 N Davidson

Simple to use and very useful.

07 Jul 2008 ? ?

Excellent

25 Jul 2008 P Jop

very usefull with command-line functions

04 Aug 2008 M Lidierth

Used the GUI menu without any hitches. Intuitive and easy-to-use. Excellent.

21 Aug 2008 Alex Liberzon

great support and improvements over the last two years.

29 Aug 2008 Jim S

Excellent and smooth!

01 Oct 2008 Chris Calvert

Just downloaded this, it looks great! Any functions I have tried (so far) work very easily and smoothly. Are there any plans to include lorentzian fitting in the tool box?

03 Oct 2008 Janina Madoff

impossible to remove their menu from your gui figures and uninstall cleanly

20 Nov 2008 Thierry Dalon

Janina and Nirvikar: do not put bad ratings only because you don't know how to use Matlab. At least read the documentation before, contact the author before or ask for support in the Newsgroup. Your rating is not fair!
To remove the menu from figures use>> efmenu off. To remove the Toolbox simply remove from Matlab path or entry in startup file if you used efmenu install.

To the author : to avoid function naming conflicts, it may be better to name all the functions in the Toolbox with a common prefix like 'ef'.

01 Dec 2008 Timo

Take a look at the known problems: "If the Ezyfit toolbox has been installed using efmenu, all GUI figure windows created using GUIDE have the Ezyfit menu included. Uninstalling the Ezyfit toolbox produces an error, since the GUI looks for the menu which is not available. No solution for the moment."
Using efmenu off does not remove the menus.
This is a clear minus for an otherwise very useful toolbox.

12 Dec 2008 Frederic Moisy  
12 Dec 2008 Frederic Moisy

(Sorry for the unintentional rating of my own file on my previous post!)

TO UNINSTALL THE EZYFIT TOOLBOX:
1. Edit the 'startup.m' file (type 'edit startup') and remove the 2 lines starting with 'efmenu' and 'fprintf()'
2. Go the menu 'File', 'Set Path', and remove the directory 'ezyfit'
3. Restart Matlab

CONCERNING THE ISSUE OF THE EZYFIT MENU IN SAVED FIGURES AND GUIs:
Sorry for this bug, I have no idea on how to fix it. Suggestions are welcome. Note that you can use the Ezyfit toolbox without using the Ezyfit menu. For this, apply step 1 above.

Hope this helps - The author.

23 Dec 2008 Janina

Thierry Dalon -
No need to sling insults like a common blogger. I had assumed better of Matlab users. I am referring to the bug the Frederic Moisy himself identified - that it is difficult to remove the ezfit menu from previously saved figures. I have indeed removed the ezfit menu. I reloaded my figure generating scripts, and all was well. Thank you Frederic, for your feedback.

26 Jan 2009 Soumitra Deshmukh

Does it work with earlier versions of Matlab such as 6.5 ?

26 Jan 2009 Michael Jordan  
11 Feb 2009 Cezar

Excellent tool! Many thanks!!!

11 Mar 2009 Thanos

Very useful and well explained. Thank you!

19 Mar 2009 Roy  
19 Mar 2009 Sonali  
03 Apr 2009 Florian  
06 May 2009 Clemens Listner

Thank you for this great toolbox

26 May 2009 Erdal Bizkevelci  
26 May 2009 Farah

I just downloaded this and it's great! Very easy to use and non-cluttered. 5 over 5! Is there any where I can obtain more in-depth information about how it works and what the output values really mean? That would be superb.

29 May 2009 Antony Lee

The package is really great! However, I would like to know whether it is possible to have some fixed parameter values when using ezfit, eg.
ezfit(x,y,'y(x)=a*x+b')
assuming that I know the actual value of a and want only the fit for b. (Of course if a=3 or some other value I could write ezfit(x,y,'y=3*x+b'), but I want to include this in a script, so a would be a variable...)

02 Jun 2009 Roy  
16 Jun 2009 Arnold

Awesome toolbox. Instrumental in my research.

16 Jul 2009 Erdal Bizkevelci  
31 Jul 2009 Andrew Barrow

Fantastic tool. This is incredibly useful. Especially if you use the "data paintbrush" tool in the figure window.

02 Sep 2009 Stefan Gachter

Excellent tool!

07 Sep 2009 Muhammad Tauha Ali

splendid tool. inclusion of statistical tests such as RMSE, t-statistics and R-squared statistics in ezyfit menu will enhance the functionality of the toolbox.

16 Sep 2009 Dave Robinson

Nice application, seems to do everything it says on the box

22 Oct 2009 Andres Klever

Hi Frederic, well im sending you this mail because i have a problem with this tool, first of all say to you thanks for this tool i think that is really good, ok , so there are 2 problems:

1) i have a problem with the weight
 In order to perform a weighted fit on this data, the vectors y and dy have to be merged into a 2-by-N matrix and given as the second input argument to ezfit. Compare the results for the usual and weighted fits:
fw = ezfit(x, [y;dy], 'exp');
showfit(fw,'fitcolor','red');
f = ezfit(x, y, 'exp');
showfit(f,'fitcolor','blue');
my problem is that when i do this (exactly the same) the data [y;dy] is from a different size than x, so obiously i get this error:

??? Error using ==> ezfit at 272
X and Y dimensions must agree.

if you can help me with this it would be great..

2)the other problem is that when i plot more than one fit for the same data, the plot just shows one legend that is pasted into the other legend, hahaha, so i just can see one of the 2 legends that should appear (showing me the different equations)...

ok, frederic sorry for asking you this questions but i really need to know this,

thanks very much,

23 Oct 2009 Frederic Moisy

Dear Andres,

Problem #1: This occurs if y and dy are column vectors instead of row vectors. If this is the case, then just replace [y; dy] by [y, dy]

Problem #2: Move the equation box using the mouse.

-- The author

18 Nov 2009 ihsan

Great toolbox!!! Many Thanks.

21 Nov 2009 Massimo

Dear Frederic,
is it possible to associate the error to the estimated parameters?
Thanks

05 Dec 2009 Ritesh  
15 Jan 2010 Arthur

Very usefull!

18 Jan 2010 Mathieu

This tool is excellent! It makes life so much easier!
Thanks Fred!!!!
And BRAVO!!!!

26 Feb 2010 Oliver  
11 Mar 2010 anurag pandey

it's a fabulous tool bar, which solved my problem i was struggling to get done for quite some time. I have a query about it, that what you do if you want to fit just a part of your data(curve).

23 Apr 2010 Melanie Mu

Great tool! It's almost perfect! I am only missing two things; I would really love if it could also:
1) fit data with error bars in both directions
2) display the errors associated with the fit parameter results.

25 Apr 2010 Xiao Ling

very useful tool! Thanks a lot

13 Jun 2010 Shahriar

Excellent toolbox! Very useful. Thanks!!

21 Jun 2010 Brad Ridder

Its amazing in every way.
A gold-standard for user-submitted toolboxes.

A job well-done! Bravo!

15 Jul 2010 Matthias

You're a champion for creating this!
Thanks very much...

I do have a couple of questions I would like to ask:

When you say "There is no way for the moment to change this number of iterations in EzyFit", I am a bit confused by this. In fminsearch the default for 'MaxInter' and 'MaxFunEvals' are both '200*numberOfVariables'.

I have set these to 2000000*numberOfVariables but I still run into the exact same error when using:
ezfit(x,y, a1*exp(-b1*x)+a2*exp(-b2*x)+y0)

The error is:
Exiting: Maximum number of function evaluations has been exceeded
         - increase MaxFunEvals option.
         Current function value: 30502.906917

Also, since MaxInter and MaxfunEvals both must be integer values, I do not understand how the iteration above can have decimal values. Or maybe I am misinterpreting it?

The other thing I wanted to say is that if run fminsearch and call fitfun as per the code below, fminsearch is able to generate a perfect 3 exponent decay function in 175 iterations (i.e., much lower than 30502.906917). I should think ezfit should be able to achieve the exact same result if allowed to iterate within definable constraints (see TollX and TollFun below), because it also uses fminsearch.

Finally, probably a dumb question, how come 'showfit' will work when I supply a 3 (or 2) exponent function but ezfit fails with the above iteration error?

Looking forward to reading your answers......this is otherwise a brilliant toolbox.

Best regards,
Matthias

code:
-------
% Define initial paramters

t = x;
y = y;
    % Grab x and y values generated in ginput

TolFun = .000000001;
TolX = 0.1;
    % TolFun = Termination tolerance on the function value
    % TolX = Termination tolerance on x

% Plot x and y

set(0,'DefaultFigureWindowStyle','docked')
    figure;plot(t,y,'ro')
    hold on
    h = plot(t,y,'b');
    hold off
    title('Input data')
start = [0;0;0];
    % Define starting lambdas (initial guesses)

outputFcn = @(x,optimvalues,state) fitoutputfun(x,optimvalues,state,t,y,h);
    % User defined output function for each iteration of fminsearch

options = optimset('OutputFcn',outputFcn,'TolX',TolX,'TolFun',TolFun, 'Display', 'iter');
    % Options for fminsearch

estimated_lambda = fminsearch(@(x)fitfun_v2(x,t,y),start,options);

21 Sep 2010 Christopher Coello

Great, great toolbox, really useful.
One possible improvment: to handle subplot command in the display using showfit. Now, when doing subplot, the info about the fit always shows on the first subplot (subplot(xxx,xxx,1)).

21 Sep 2010 Siva

Just great !

08 Nov 2010 Patrick

Very helpful tool! In stock form, can't handle completely arbitrary fit functions; EQ2ML doesn't convert parameters in expressions such as 'myfitfun(K,x)' to the required m(i) format for fminsearch, since it treats 'K,x' as a single token. This is quickly fixed by adding ',' to the list of delimiters used by FINDWORD, after which it handles that input just fine.

Along those lines, it would be nice if you could specify the fit function using a handle; restricting the 'x' variable to be either the first or last free variable in the handle/anonymous function should allow that.

13 Dec 2010 Liang Jin

Great features and easy to use.

21 Dec 2010 Basim Kakakhel

An excellent utility, I am having little trouble in running the following.

I have two vectors of 360 elements each.

First vector is y which contains the pixel number from 1-360

the second vector is c, it contains the values for the y vector.

the aim is to fit a function similar to this

y=a(1-exp(b*c))

I am more interested in the a coefficient. However i am getting the following error.

 ezfit(y,c,'y=a*(1-exp(-b*c)')
??? Error using ==> ezfit at 549
Fit: error during the fminsearch procedure

22 Dec 2010 Frederic Moisy

Dear Basim Kakakhel,
Please try the following: ezfit(c,y,'y(c)=a*(1-exp(-b*c)')

12 Jan 2011 Al Ka

Very good plugin but I have a serious problem with evalfit(). I have the following code:

x = [1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749];
x= x';

y = 1.0e+03 * [1.0408 1.0392 1.0376 1.0362 1.0348 1.0335 1.0323 1.0312 1.0302 1.0293 1.0285 1.0278 1.0271 1.0266 1.0261 1.0258 1.0255];
y=y';

f = ezfit(x,y,'y=20-a*10*log(x)');

figure; plot(f.x,f.y, 'b-');
figure; plot(x,evalfit(f,x),'r-');

If you run it you will see that the two plots are way off while they should be almost identical. I guess. Please let me know what I am doing wrong.

I want to use evalfit to extrapolate some data. Thank you in advance!

13 Feb 2011 Wesley  
14 Mar 2011 Roman Voronov

Please add support for NaN values

13 Apr 2011 Kassi

I would also like support for NaN values, please! :)

04 May 2011 Francois Anquez

Very Nice tool !
Easy and rapid handle. Something that sometime miss me with matlab...

Thanks to the author.

27 May 2011 rene  
27 May 2011 rene

Brilliant plugin, though i had problems getting it to work with matlab 2010a.
If anybody else is having problems with getslope.m you have to change line 76 from
if v>=7.4
to
if v>=7.4 || regexp(strv,'.*R20\d\d.*')==1

This should correct the version detection.

16 Jun 2011 vick Audi

Problem with unistallation:

Even after following your following recommended steps (under full unistallation):
Full uninstallation

In order to remove the Ezyfit toolbox from your Matlab installation, follow the 3 steps:

1. Edit the 'startup file' by typing

edit startup
        
and remove the following lines

% These lines have been added by 'efmenu install' (01-Apr-2008 23:10:11):
efmenu; % Includes the EzyFit menu for all new figure.
fprintf(' To get started with the EzyFit toolbox, select EzyFit from the Help browser.\n\n');
        
2. From the menu 'File > Set Path', select the directory '../ezyfit', and click on 'Remove' and 'Save'.

3. Restart Matab.

%*************************************%
I'm getting the following error when I run my GUI:
%*************************************%

??? Error using ==> struct2handle
Undefined function or variable 'efmenu'.
 
??? Error using ==> struct2handle
Error while evaluating figure CreateFcn

%*************************************%

This is getting a little annoying now. Kindly suggest a fix. Thanks

09 Aug 2011 Carl  
11 Aug 2011 Thorsten Maly  
03 Nov 2011 Homerarg  
22 Nov 2011 João Faria  
02 Dec 2011 Nathan Tomlin  
20 Dec 2011 Yvonne Haesevoets

Great tool. Thanks for sharing.

Please login to add a comment or rating.
Updates
09 Mar 2006

minor bugs fixed (see the release notes in the help browser).

09 Mar 2006

Minor bugs fixed (see the release notes in the help browser)

18 Apr 2006

The 'EasyFit' toolbox has been renamed 'EzyFit', in order to avoid confusion with other existing products.

06 Sep 2006

New version (2.04)
A FAQ is now included
Minor bugs fixed

07 Sep 2006

help text improved

30 Oct 2006

New version 2.10: See the 'release notes' page for changes.

07 Mar 2008

New version 2.20. See release notes for details.

09 Mar 2008

Description text improved

05 Feb 2009

Now suport the "Data Brushing" tool of Matlab 7.6

05 Feb 2009

Added support to the "Data Brushing" tool (Matlab 7.6)

29 Jul 2010

Bug fixed : the figure files (.FIG) and user interfaces (GUI) were corrupted with the Ezyfit menu. This issue has been fixed. See the new function "remove_efmenu_fig.m".

Tag Activity for this File
Tag Applied By Date/Time
approximation Frederic Moisy 22 Oct 2008 08:17:03
interpolation Frederic Moisy 22 Oct 2008 08:17:03
curve Frederic Moisy 22 Oct 2008 08:17:03
fitting Frederic Moisy 22 Oct 2008 08:17:03
nonlinear Frederic Moisy 22 Oct 2008 08:17:03
mathematics Frederic Moisy 22 Oct 2008 08:17:03
fit Frederic Moisy 22 Oct 2008 08:17:03
curve omzaz 09 Sep 2009 06:34:16
vetor creating in workspace Sandeep gande 20 Oct 2009 22:05:14
vectorise the columns of a matrix Sandeep gande 20 Oct 2009 22:07:19

Contact us at files@mathworks.com