fitGompertz

PURPOSE ^

FITGOMPERTZ return cfitObject by fitting Gompertz function

SYNOPSIS ^

function [ cfitObject, sseError ] = fitGompertz( inputT, acutalOutput )

DESCRIPTION ^

 FITGOMPERTZ return cfitObject by fitting Gompertz function

   [ cfitObject, sseError ] = fitGompertz( inputT, acutalOutput )
   Based on inputT and acutalOutput, this function return cfitObject fitting
   with Gompertz function.
   Gompertz function: y(t) = a * exp(b * exp(c * t))

   Input:
       inputT: value of input t
       acutalOutput: output of input t

   Output:
       cfitObject: cfit object of fitting result
       sseError: sum square error of fitting result

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ cfitObject, sseError ] = fitGompertz( inputT, acutalOutput )
0002 % FITGOMPERTZ return cfitObject by fitting Gompertz function
0003 %
0004 %   [ cfitObject, sseError ] = fitGompertz( inputT, acutalOutput )
0005 %   Based on inputT and acutalOutput, this function return cfitObject fitting
0006 %   with Gompertz function.
0007 %   Gompertz function: y(t) = a * exp(b * exp(c * t))
0008 %
0009 %   Input:
0010 %       inputT: value of input t
0011 %       acutalOutput: output of input t
0012 %
0013 %   Output:
0014 %       cfitObject: cfit object of fitting result
0015 %       sseError: sum square error of fitting result
0016 
0017 %   ---------
0018 %   Yen-Nan Lin, NTHU, 2010-2014, Matlab 2012a
0019 
0020 DEFAULT_PARAMETER = [1 -4 -5];
0021 options = optimset('MaxFunEvals', 1000, 'TolFun',1e-18, 'MaxIter', 1000);
0022 [estimateParameter, sseError] = fminsearch(@sseFitGompertz, ...
0023     DEFAULT_PARAMETER, options, inputT, acutalOutput);
0024 a = estimateParameter(1);
0025 b = estimateParameter(2);
0026 c = estimateParameter(3);
0027 cfitObject = cfit(fittype('a * exp(b * exp(c * x))'), a, b, c);
0028 end
0029 
0030 function [ sumSquareError ] = sseFitGompertz( params, inputT, acutalOutput )
0031 % sum square error of fitting function
0032 a = params(1);
0033 b = params(2);
0034 c = params(3);
0035 fittedGompertz = a * exp(b * exp(c * inputT));
0036 errorVector = fittedGompertz - acutalOutput;
0037 sumSquareError = sum(errorVector.^2);
0038 end

Generated on Thu 30-Jan-2014 00:00:07 by m2html © 2005