Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.9K Views
|
8 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Need help to fix the syntax error in plotting

Posted 12 years ago

hi, I am working on a model. I tried to fit the model to the data. After fitting the model, I tried to plot the graph, but it is showing some error. Please help me to fix the problem. Attached the file for reference.

Thanks

Thanks, Jaydeep

Attachments:
POSTED BY: Jaydeep Yadav
8 Replies
Posted 12 years ago

I was unable to find any difference between the two. I also went through your previous comment where you showed the code for both the problems. But I was unable to find the difference. In case if you know the difference,please let me know that might be the reason why one of them is not working.

Thanks

POSTED BY: Jaydeep Yadav
Posted 12 years ago
POSTED BY: Bill Simpson
Posted 12 years ago
POSTED BY: Jaydeep Yadav
Posted 12 years ago

Compare word by word, character by character this, which you claim works,

model5[k2_?NumericQ, k3_?NumericQ, S0_?NumericQ] :=
  (model5[k2, k3, k4, S0] = P[10] /. First[NDSolve[{
        Eu'[t] == k2 ES[t] + k3 ES[t] - k1 Eu[t] S[t] - k4 Eu[t],
        ES'[t] == k1 Eu[t] S[t] - ES[t] (k2 + k3),
        E2'[t] == k4 Eu[t], S'[t] == k2 ES[t] - k1 Eu[t] S[t], P'[t] == k3 ES[t],
        S[0] == S0, Eu[0] == Et, ES[0] == 0, E2[0] == 0, P[0] == 0},
       {Eu, ES, E2, S, P}, {t, 0, 60}]]);
fit = NonlinearModelFit[data, model5[k2, k3, S0],
{{k2, 4000}, {k3, 100}},
S0]

with this, which you claim does not work

Model3[Vmax_?NumericQ, Km_?NumericQ, Fuc_?NumericQ, Pdiff_?NumericQ, Cb0_?NumericQ, te_] :=
  (Model3[Vmax, Km, Fuc, Pdiff, Cb0, te] = Ca[te] /. First[NDSolve[{ 
        Ca'[t] == ((Vmax Cb[t])/(Km + Cb[t]) - Pdiff Fuc Ca[t] + Pdiff Cb[t])/Va, 
        Cb'[t] == (Pdiff Fuc Ca[t] - Pdiff Cb[t] - (Vmax Cb[t])/(Km + Cb[t]))/Vb,
        Ca[0] == 0, Cb[0] == Cb0 },
       {Ca, Cb}, {t, 0, 50}]]);
fit1 = NonlinearModelFit[Dataimp, {Model3[Vmax, Km, Fuc, Pdiff, Cb0, te]},
{{Vmax, 0.001119}, {Km, 15}, {Fuc, 0.1}, {Pdiff, 0.000000345}}, {Cb0, te},
   Weights -> (1/#3 &)]

What is different? Is it absolutely necessary that it be different?

Why is Cb0 and te written differently than P? Why is Ca written differently than P? Are there other differences? That can be made the same?

POSTED BY: Bill Simpson
Posted 12 years ago

HI, Thanks for your efforts. I am attaching the file, where I had used these functions, earlier. They had worked. But I am not able to find the mistake which I am doing in "error.nb" .

Thanks for the help

Attachments:
POSTED BY: Jaydeep Yadav
Posted 12 years ago
POSTED BY: Bill Simpson
Posted 12 years ago
Attachments:
POSTED BY: Jaydeep Yadav
Posted 12 years ago

In your attached error.nb notebook

Error 1: Va and Vb are not assigned numeric values, but you are using those inside NDSolve that that will always fail. It is very unfortunate that an error message from NDSolve did not tell you this in exactly those words.

Error 2: You are solving for Cb0 and te in your NonlinearModelFit and you will then need to evaluate the resulting fit1 with two arguments, but you are only giving it one argument in fit1[Ca[te]]. The error message tells you exactly this same thing. After many other changes to try to get NonlinearModelFit to produce any kind of result without failure I was able to get fit1[1,1] to provide one result without errors, but that was not even attempting to plot fit1[1,t].

But these are the smallest and most obvious errors of what is probably a forest of other problems and errors and misunderstandings.

I cannot know, but it appears from the way that parts of this are written that you are randomly inserting things that you have seen elsewhere and hoping that they have something to do with your problem.

Example from your code

Model3[Vmax_?NumericQ, Km_?NumericQ, Fuc_?NumericQ, Pdiff_?NumericQ, Cb0_?NumericQ, te_] :=
  Model3[Vmax, Km, Fuc, Pdiff, Cb0] = ...

I believe you have seen some code from somewhere use this and so you think this must necessary and so you insert it in your code. But the number of arguments is not the same in those two Model3. There is a purpose in using this method of writing functions, but I believe this is probably the least of all the problems you have now and is not doing anything correct in your code.

You may not have begun by first learning a considerable amount about Mathematica programming and then started this project by writing the smallest bits of code, testing that to make certain that you really understand exactly how it works and that it is correct, then adding the smallest possible additional bit of code to get slightly closer to your entire problem and repeating the understanding and testing process over and over and over and over until you get to your final result.

I attempted to do some of that process by making many changes and fumbling around and was able to figure out and I believe correct some things in the code to try to get small parts of this to work, but I cannot begin to guess how to tell you how to "fix your problem."

Do you possibly have any other tools that you could start over with and solve this problem using them? That might be easier and faster.

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