-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsigmoidfit.m
41 lines (33 loc) · 1.08 KB
/
sigmoidfit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [fitresult, gof] = sigmoidfit(narssdbins, probaresp)
%CREATEFIT(NARSSDBINS,PROBARESP)
% Create a fit.
%
% Data for 'sigmoid' fit:
% X Input : narssdbins
% Y Output: probaresp
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% MATLAB auto-generated on 15-Nov-2012 00:26:53 by VP
%should use glmfit such as b = glmfit(x,[y n],'binomial','link','probit');
%% Fit: 'sigmoid'.
[xData, yData] = prepareCurveData( narssdbins, probaresp );
% Set up fittype and options.
ft = fittype( '1./(1+exp(-(x/2-a)/(10)))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = -Inf;
opts.StartPoint = 0.251083857976031;
opts.Upper = Inf;
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
% figure( 'Name', 'sigmoid' );
% h = plot( fitresult, xData, yData );
% legend( h, 'probaresp vs. narssdbins', 'sigmoid', 'Location', 'NorthEast' );
% % Label axes
% xlabel( 'narssdbins' );
% ylabel( 'probaresp' );
% grid on