Contents

Load my model

dataModel    = loadModel('OneStep');

Simulatate our "real model"

we use the nominal model to generate some data

exp1 = constructExperiment(30*60, 10);
data = simulate(dataModel, exp1);

Scramble the parameters onthe model

m   = dataModel;
m.p = m.p.*random('log',0,0.5,size(dataModel.p));
m   = postProcessModel(m);

beforeFit = simulate(m, exp1);


% Plot the data and the model before the fit on the same axis
figure(1),clf
plot(data.t, data.y(data.t), 'o'); hold on;
drawnow;
plot(beforeFit.t, beforeFit.y(beforeFit.t), '--'); hold off;
disp('Hit any Key to continue'); pause;
Hit any Key to continue

Fit the new model to data generated from the old model

figure(2),clf
obj = constructObjectiveOutputISE(m, 1:m.nY, data.y);
[mFit,G] = fitParameters(m, obj, exp1);
afterFit = simulate(mFit, exp1);
                                max     Line search  Directional  First-order 
 Iter F-count        f(x)   constraint   steplength   derivative   optimality Procedure 
    0      1      82.2703      -0.0109                                         
    1      4      58.2864     -0.01176     0.000501    3.28e+005    4.27e+005   
    2      6      48.6478     -0.02354        0.001    6.04e+003    2.33e+004   
    3      8      34.5166     -0.02663       0.0233         -200    1.25e+003   
    4     12      32.9864     -0.02456       0.0778         13.1    2.65e+003   
    5     16      32.4782     -0.02448      0.00332         55.3    2.47e+003   
    6     20      28.1936     -0.02332         0.25        -14.4          696   
    7     23        5.686     -0.01166          0.5        -27.1    5.71e+003  Hessian modified  
    8     27      2.64897    -0.008745         0.25           31    6.09e+003   
    9     30      2.62306     -0.01259         0.06         37.3    5.11e+003   
   10     34     0.654004     -0.01574       0.0542         2.38          800   
   11     40      0.48107     -0.01658       0.0388          5.2    1.27e+003   
   12     43     0.221215     -0.01567          0.5         1.76          690   
   13     45   0.00785286     -0.01599            1      -0.0668          108   
   14     47   0.00038813       -0.016            1      0.00108         5.76   
   15     49   0.00035435       -0.016            1    1.18e-006        0.924   
Optimization terminated: magnitude of directional derivative in search
 direction less than 2*options.TolFun and maximum constraint violation
  is less than options.TolCon.
No active inequalities.

Plot the results

figure(3),clf
plot(data.t, data.y(data.t), 'o'); hold on;
plot(beforeFit.t, beforeFit.y(beforeFit.t), '--');
plot(afterFit.t, afterFit.y(afterFit.t), '-');
hold off;