Code covered by the BSD License

### Highlights from Fit Logistic Curve to a Data Set

5.0
5.0 | 1 rating Rate this file 17 Downloads (last 30 days) File Size: 11.7 KB File ID: #31399

# Fit Logistic Curve to a Data Set

### Varuna De Silva (view profile)

10 May 2011 (Updated )

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

File Information
Description

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

MATLAB release MATLAB 7.5 (R2007b)
04 Jul 2014 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{:});

Comment only
16 May 2013 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.

Comment only
14 Jun 2012 Ryan

23 Feb 2012 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

Comment only
15 Feb 2012 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

Comment only
16 Nov 2011 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....

Comment only
16 Oct 2011 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

Comment only
15 Jul 2011 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

Comment only
30 Jun 2011 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!

Comment only