File Exchange

## 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.

4.33333
3 Ratings

Updated

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

http://online.redwoods.cc.ca.us/instruct/darnold/diffeq/logistic/logistic.pdf

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

Dave White

Nice Tool!

sky sumbra

### sky sumbra (view profile)

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

Aishwarya Gunaputi

### Aishwarya Gunaputi (view profile)

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

Lu

### Lu (view profile)

hi Varuna De Silva,

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

Error in ==> Logistic>plotBut_Callback at 159
axes(handles.axes1)

Error in ==> gui_mainfcn at 96
feval(varargin{:});

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

??? Error while evaluating uicontrol Callback

Varuna De Silva

### Varuna De Silva (view profile)

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

### D Bhuiyan (view profile)

Hello Varuna De Silva,
How can I get the curve fitting by using linear polynomial method (y=p1*x+p2)?
thanks....

Michael

### Michael (view profile)

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.
Thanks

Varuna De Silva

### Varuna De Silva (view profile)

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

### 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!