File Exchange

image thumbnail

Fit Logistic Curve to a Data Set

version 1.1 (11.7 KB) by

This is a Matlab GUI, that will try to fit a logistic function to a given set of data.

3 Ratings



View License

The method used in this work is based on a tutorial by David Arnold.

RUN The Logistic.m this will bring up the GUI.

1. Give the x values on a text file in column format
2. Give the y values on a text file in col format
3. 'Plot Initial' Button will plot the distribution
4. 'Find Fit' button will find the best fit
5. 'Reset' will remove the plot (Although I wanted to clean all the fields - did not have time)
5. K, G, Dm are the values in the following equation

y = K./(1+exp(-G*(x-Dm)));

6. SSE gives the sum of squred error between the fitted function and the actual data
7. CC give the correlation co-efficient between the fitted function and actual data

Comments and Ratings (11)

Dave White

Nice Tool!

sky sumbra

hi Varuna De Silva,
Try a negative value, appearance error curve..

Sir, I got these errors after running this code. Can u please tell how to solve this problem.

??? Error using ==> feval
Undefined function or method 'Logistic_OpeningFcn' for input arguments of type 'struct'.

Error in ==> gui_mainfcn at 221
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in ==> Logistic at 31
gui_mainfcn(gui_State, varargin{:});

James Conder

James Conder (view profile)

I suspect the problem Rita and Michael were having is that their data describes a decreasing logistic and the program is set up to do an increasing logistic. I just uploaded a non-GUI fit_logistic function and at first it failed with Rita's data, too. Fortunately, it is an easy fix by making the time series negative.


Ryan (view profile)


Lu (view profile)

hi Varuna De Silva,

This is the errors I received while following your instructions on the readme.txt

??? Attempt to reference field of non-structure array.

Error in ==> Logistic>plotBut_Callback at 159

Error in ==> gui_mainfcn at 96

Error in ==> Logistic at 30
gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback

Varuna De Silva

Dear Rita and Michael,

Please check to see if your problem is solved in this new version.

Hopefully it is right this time.

BR, Varuna

D Bhuiyan

Hello Varuna De Silva,
Thanks for nice program. Can you please help about the following question?
How can I get the curve fitting by using linear polynomial method (y=p1*x+p2)?


Hi Varuna De Silva,
this is really a great program (and it's almost what I need), but I have the same problem as Rita described. It would be great if it could be fixed somehow.

Varuna De Silva

Hello Rita,

Yes, I tried your data, and it seems in the CC estimation it divides by zero. I couldnt find a quick way out. I will do so and return later


Rita (view profile)

This program looks great and I was very excited with using it but it doesn't seem to like my data. I have for instance X=[.2;.4;.6;.7;.8;.9;1] and Y=[95;90;90;70;65;55;50]. When I press 'plot inital' it looks ok, but when I press 'find it' I get the message 'Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: -Inf' with K=-Inf and s_sq_e=NaN.
Would be great if you could explain who to get this right. Thanks!



Bug fixes in parameter estimation process. Thanks to Prof. Sean Crosson for directing me to those errors.

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video