%% Example 1 Stepwise transition with noise

f = 

     General model:
     f(x) = a+b*(1./(1+exp(-d*(x-c))))
     Coefficients (with 95% confidence bounds):
       a =     0.02369  (-0.01299, 0.06038)
       b =      0.9788  (0.9264, 1.031)
       c =       50.07  (49.17, 50.97)
       d =      0.5025  (0.3052, 0.6998)

fgof = 

  struct with fields:

           sse: 1.3848
       rsquare: 0.9409
           dfe: 96
    adjrsquare: 0.9390
          rmse: 0.1201


fout = 

  struct with fields:

           numobs: 100
         numparam: 4
        residuals: [100×1 double]
         Jacobian: [100×4 double]
         exitflag: 3
    firstorderopt: 0.0010
       iterations: 14
        funcCount: 75
     cgiterations: 0
        algorithm: 'trust-region-reflective'
         stepsize: 0.0017
          message: 'Success, but fitting stopped because change in residuals less than tolerance (TolFun).'

%% Example 2 Rampwise transition with noise

f = 

     General model:
     f(x) = a+b*(1./(1+exp(-d*(x-c))))
     Coefficients (with 95% confidence bounds):
       a =     0.03803  (-0.0166, 0.09266)
       b =       0.976  (0.8866, 1.065)
       c =        51.4  (48.87, 53.93)
       d =      0.1104  (0.08136, 0.1394)

fgof = 

  struct with fields:

           sse: 1.2676
       rsquare: 0.9232
           dfe: 96
    adjrsquare: 0.9208
          rmse: 0.1149


fout = 

  struct with fields:

           numobs: 100
         numparam: 4
        residuals: [100×1 double]
         Jacobian: [100×4 double]
         exitflag: 3
    firstorderopt: 0.0013
       iterations: 15
        funcCount: 80
     cgiterations: 0
        algorithm: 'trust-region-reflective'
         stepsize: 2.9819e-04
          message: 'Success, but fitting stopped because change in residuals less than tolerance (TolFun).'

%% Example 3 Gradual transition with noise

f = 

     General model:
     f(x) = a+b*(1./(1+exp(-d*(x-c))))
     Coefficients (with 95% confidence bounds):
       a =     -0.1046  (-0.627, 0.4177)
       b =       1.358  (0.1445, 2.572)
       c =       57.05  (36.85, 77.24)
       d =     0.03064  (-0.002477, 0.06376)

fgof = 

  struct with fields:

           sse: 1.2784
       rsquare: 0.8494
           dfe: 96
    adjrsquare: 0.8447
          rmse: 0.1154


fout = 

  struct with fields:

           numobs: 100
         numparam: 4
        residuals: [100×1 double]
         Jacobian: [100×4 double]
         exitflag: 3
    firstorderopt: 1.4201e-04
       iterations: 15
        funcCount: 80
     cgiterations: 0
        algorithm: 'trust-region-reflective'
         stepsize: 0.0046
          message: 'Success, but fitting stopped because change in residuals less than tolerance (TolFun).'

%% Example 4 Gradual change with noise but with a large gap

f = 

     General model:
     f(x) = a+b*(1./(1+exp(-d*(x-c))))
     Coefficients (with 95% confidence bounds):
       a =     -0.1217  (-0.7781, 0.5346)
       b =       1.488  (-0.3325, 3.308)
       c =       62.91  (23.59, 102.2)
       d =     0.02775  (-0.01068, 0.06618)

fgof = 

  struct with fields:

           sse: 1.1205
       rsquare: 0.8626
           dfe: 76
    adjrsquare: 0.8572
          rmse: 0.1214


fout = 

  struct with fields:

           numobs: 80
         numparam: 4
        residuals: [80×1 double]
         Jacobian: [80×4 double]
         exitflag: 3
    firstorderopt: 3.8919e-04
       iterations: 17
        funcCount: 90
     cgiterations: 0
        algorithm: 'trust-region-reflective'
         stepsize: 0.0124
          message: 'Success, but fitting stopped because change in residuals less than tolerance (TolFun).'

>> 