Message Boards Message Boards

0
|
9644 Views
|
5 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Need help for removing the coding error

Posted 11 years ago

hi, I am working on a model. I tried to fit the model to the data. But it is showing some error, I was unable to find the mistake. Please help me find the cause of the error

Thanks

Thanks, Jaydeep

Attachments:
POSTED BY: Jaydeep Yadav
5 Replies
Posted 11 years ago

Hey, Can you please help me identify the correct plot in this file. I have plotted two plots "F4" and "F5". There is a slight difference in the range of the interpolating function. Can you please help me to recognize which of the above plots is the correct plot. And if possible the reason if one of them is wrong.

Thanks,

Attachments:
POSTED BY: Jaydeep Yadav
Posted 11 years ago

Hey, thank you. I realized what I was doing wrong.

Thanks.

POSTED BY: Jaydeep Yadav
Posted 11 years ago

Hi, Sorry for that. I am attaching the excel file for the same. Thanks

Attachments:
POSTED BY: Jaydeep Yadav

Hi Jaydeep,

your notebook uses (as an import) an Excel-Sheet, which is not included to your post, so I cannot reproduce the error.

Greetings from Germany

Mike

POSTED BY: Michael Gamer

The notebook contains all the data in its present form. You can simply type

Dataimp = {{0.0459664, 5., 0.000731}, {0.0459664, 10., 0.00136}, {0.0459664, 
  15., 0.00195}, {0.0459664, 20., 0.00255}, {0.0459664, 30., 
  0.00356}, {0.0459664, 40., 0.00469}, {0.0459664, 60., 
  0.0059}, {0.0766106, 5., 0.00106}, {0.0766106, 10., 
  0.00208}, {0.0766106, 15., 0.00301}, {0.0766106, 20., 
  0.00407}, {0.0766106, 30., 0.00577}, {0.0766106, 40., 
  0.00719}, {0.0766106, 60., 0.00889}, {0.127684, 5., 
  0.0018}, {0.127684, 10., 0.0036}, {0.127684, 15., 
  0.00502}, {0.127684, 20., 0.00633}, {0.127684, 30., 
  0.00939}, {0.127684, 40., 0.0116}, {0.127684, 60., 
  0.0143}, {0.212807, 5., 0.00263}, {0.212807, 10., 
  0.00518}, {0.212807, 15., 0.00744}, {0.212807, 20., 
  0.00939}, {0.212807, 30., 0.0134}, {0.212807, 40., 
  0.0168}, {0.212807, 60., 0.0211}, {0.354679, 5., 
  0.00441}, {0.354679, 10., 0.00846}, {0.354679, 15., 
  0.0121}, {0.354679, 20., 0.0162}, {0.354679, 30., 
  0.0229}, {0.354679, 40., 0.0276}, {0.354679, 60., 
  0.0328}, {0.591132, 5., 0.00701}, {0.591132, 10., 
  0.0133}, {0.591132, 15., 0.0207}, {0.591132, 20., 
  0.0257}, {0.591132, 30., 0.0352}, {0.591132, 40., 
  0.0435}, {0.591132, 60., 0.0518}, {0.985219, 5., 0.0109}, {0.985219,
   10., 0.0223}, {0.985219, 15., 0.0306}, {0.985219, 20., 
  0.0388}, {0.985219, 30., 0.0577}, {0.985219, 40., 
  0.0691}, {0.985219, 60., 0.0791}, {1.64203, 5., 0.0174}, {1.64203, 
  10., 0.034}, {1.64203, 15., 0.0468}, {1.64203, 20., 
  0.0604}, {1.64203, 30., 0.0895}, {1.64203, 40., 0.105}, {1.64203, 
  60., 0.119}, {2.73672, 5., 0.025}, {2.73672, 10., 0.0473}, {2.73672,
   15., 0.0675}, {2.73672, 20., 0.0844}, {2.73672, 30., 
  0.114}, {2.73672, 40., 0.145}, {2.73672, 60., 0.16}, {4.5612, 5., 
  0.0332}, {4.5612, 10., 0.0652}, {4.5612, 15., 0.0867}, {4.5612, 20.,
   0.107}, {4.5612, 30., 0.143}, {4.5612, 40., 0.167}, {4.5612, 60., 
  0.188}, {7.602, 5., 0.0393}, {7.602, 10., 0.0707}, {7.602, 15., 
  0.0965}, {7.602, 20., 0.116}, {7.602, 30., 0.155}, {7.602, 40., 
  0.174}, {7.602, 60., 0.17}, {12.67, 5., 0.0337}, {12.67, 10., 
  0.0566}, {12.67, 15., 0.0777}, {12.67, 20., 0.0894}, {12.67, 30., 
  0.114}, {12.67, 40., 0.121}, {12.67, 60., 0.114}, {0.396432, 5., 
  0.00108}, {0.396432, 10., 0.00191}, {0.396432, 15., 
  0.00253}, {0.396432, 20., 0.00333}, {0.396432, 30., 
  0.00472}, {0.396432, 40., 0.00606}, {0.396432, 60., 
  0.0066}, {0.773593, 5., 0.00158}, {0.773593, 10., 
  0.00301}, {0.773593, 15., 0.00395}, {0.773593, 20., 
  0.00485}, {0.773593, 30., 0.00725}, {0.773593, 40., 
  0.0089}, {0.773593, 60., 0.0104}, {1.20857, 5., 0.00243}, {1.20857, 
  10., 0.00437}, {1.20857, 15., 0.00602}, {1.20857, 20., 
  0.00738}, {1.20857, 30., 0.0105}, {1.20857, 40., 0.014}, {1.20857, 
  60., 0.0154}, {1.89131, 5., 0.0032}, {1.89131, 10., 
  0.00601}, {1.89131, 15., 0.00763}, {1.89131, 20., 
  0.00983}, {1.89131, 30., 0.0139}, {1.89131, 40., 0.0179}, {1.89131, 
  60., 0.0196}, {2.94571, 5., 0.00428}, {2.94571, 10., 
  0.00799}, {2.94571, 15., 0.0104}, {2.94571, 20., 0.0126}, {2.94571, 
  30., 0.0173}, {2.94571, 40., 0.0226}, {2.94571, 60., 
  0.0241}, {5.7813, 5., 0.00636}, {5.7813, 10., 0.0103}, {5.7813, 15.,
   0.0126}, {5.7813, 20., 0.0152}, {5.7813, 30., 0.0196}, {5.7813, 
  40., 0.0242}, {5.7813, 60., 0.0247}, {9.02984, 5., 
  0.0047}, {9.02984, 10., 0.00729}, {9.02984, 15., 0.00846}, {9.02984,
   20., 0.00975}, {9.02984, 30., 0.0119}, {9.02984, 40., 
  0.014}, {9.02984, 60., 0.0155}, {11.2873, 5., 0.00505}, {11.2873, 
  10., 0.00652}, {11.2873, 15., 0.00763}, {11.2873, 20., 
  0.0083}, {11.2873, 30., 0.00982}, {11.2873, 40., 0.011}, {11.2873, 
  60., 0.012}, {14.0954, 5., 0.00421}, {14.0954, 10., 
  0.00531}, {14.0954, 15., 0.00588}, {14.0954, 20., 
  0.00587}, {14.0954, 30., 0.00673}, {14.0954, 40., 
  0.00785}, {14.0954, 60., 0.00815}, {17.6192, 5., 0.00322}, {17.6192,
   10., 0.00342}, {17.6192, 15., 0.00358}, {17.6192, 20., 
  0.00378}, {17.6192, 30., 0.00402}, {17.6192, 40., 
  0.00463}, {17.6192, 60., 0.00468}, {22.024, 5., 0.00235}, {22.024, 
  10., 0.00236}, {22.024, 15., 0.00235}, {22.024, 20., 
  0.0024}, {22.024, 30., 0.00257}, {22.024, 40., 0.00275}, {22.024, 
  60., 0.00307}, {27.53, 5., 0.00195}, {27.53, 10., 0.00181}, {27.53, 
  15., 0.00193}, {27.53, 20., 0.00192}, {27.53, 30., 0.0021}, {27.53, 
  40., 0.00217}, {27.53, 60., 0.00229}}

This question was posted in a very similar form several times and for my replies I usually did this. It seems to work. In most of the other cases some of the variables were not defined and the numerical integration goes wrong. (The error messages make this actually quite clear!) This time the following parameters are missing:

Et = 5.; k5 = 0.2; k6 = 0.2; ki = 0.2;

If you add these before executing

model4[k1_?NumericQ, k2_?NumericQ, k3_?NumericQ, k4_?NumericQ, 
  S0_?NumericQ, 
  te_] := (model4[k1, k2, k3, k4, S0] = 
   P1[te] /. 
    First[NDSolve[{Derivative[1][Eu][t] == 
        k2 ES1[t] - k1 Eu[t] S[t] + k3 ES1[t] + k4 ES1[t] - 
         k6 Eu[t] S[t] + k5 ES2[t], 
       Derivative[1][ES1][t] == k1 Eu[t] S[t] - ES1[t] (k2 + k3 + k4),
        Derivative[1][ES2][t] == 
        k6 Eu[t] S[t] - k5 ES2[t] - ki ES2[t], 
       Derivative[1][P1][t] == k3 ES1[t], 
       Derivative[1][P2][t] == k4 ES1[t], 
       Derivative[1][E2][t] == ki ES2[t], 
       Derivative[1][S][t] == 
        k2 ES1[t] + k5 ES2[t] - k1 Eu[t] S[t] - k6 Eu[t] S[t], 
       ES2[0] == 0, S[0] == S0, Eu[0] == Et, ES1[0] == 0, P1[0] == 0, 
       P2[0] == 0, E2[0] == 0}, {ES2, S, Eu, ES1, P1, P2, E2}, {t, 0, 
       100}, MaxSteps -> 1000000, PrecisionGoal -> 6]])

and

fit = NonlinearModelFit[Dataimp, 
  model4[k1, k2, k3, k4, S0, 
   te], {{k1, 6}, {k2, 10}, {k3, 10}, {k4, 5}}, {S0, te}, 
  Weights -> (1/#3 &)]

the fitting will run through without any problems. This is the output:

FittedModel[model4[0.0006726055289741539,12.046052203842411,5.573475116321559,6.678715049526951,S0,te]]

This problem of not defining the parameters has been the normal problem in the notebooks in the other posts as well.

Best wishes, Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract