Message Boards Message Boards

0
|
8247 Views
|
7 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Fitting the data (need syntax help)

Posted 11 years ago

hi, Can you please help me to resolve some issues. I am not able to plot the graph from my fitted model. My dataset is of the form (Cb0,te,Ca}. But I am not able to plot the graph of (Ca (on y axis) Vs te (on x axis) using the fitted model. I am attaching the mathematica file as a reference.

Thanks

Thanks, Jaydeep

Attachments:
POSTED BY: Jaydeep Yadav
7 Replies

Oku Nyong: I would suggest that you start a new thread (new subject header and all that) and also include some reasonable example It could be in an attached file if it seems too long to enter directly in the post. It would be best if you also provide the mathematica code you have tried thus far.

Also you might want to look at the documentation for, say, NonlinearModelFit (accessed via Help > Documentation Center).

POSTED BY: Daniel Lichtblau

Hello, I have an issue I'm trying to fit linear piecewise fit into my experimental data to get an approximation.Can anyone assist with a script to do that since I'm new to Mathematica. Thank you.

POSTED BY: Oku Nyong
Posted 11 years ago

Hi, I have made some changes as you said, I guess now the it has worked. But I am still unable to get a the graph showing the data points and the curve from the fitted model.

Please look into it.

Thanks, Jaydeep

Attachments:
POSTED BY: Jaydeep Yadav

I do not think that the fitting procedure worked properly. And still you have not defined Va and Vb in your notebook.

M.

POSTED BY: Marco Thiel
Posted 11 years ago

Hi, thanks for the solution.

As far as the graphs are concerned,I will walk through the notebook. My dataset has three values and is of the form {Cb0,te,Ca}. Now, I have fitted the dataset to the model. After fitting the dataset, I want to see how closely the data points and the curve from the fitted model fit. In other words i want to see how closely the simulated line passes through the datapoints. So I plotted first the data points, I choosed Ca on y axis and te on y axis, and plotted the dataset (Plot at the last named"Plot1"). Now I want to draw the simulated curve. I tried but it didnt work ("Plot2"). After getting the simulated plot I just want to see how closely line passes through the point. I have entered the input for it (Show[Plot1,Plot2])

So I am not able to get Plot2, Can you please help me in getting that.

Thanks

Attachments:
POSTED BY: Jaydeep Yadav

Furthermore, as I explained when you asked before http://community.wolfram.com/groups/-/m/t/283255/ , your fitting procedure is still incorrect. You run

ClearAll[Vmax, Km, fit, Cb0, Fuc, Pdiff, te, Model3];
Model3[Vmax_?NumericQ, Km_?NumericQ, Fuc_?NumericQ, Pdiff_?NumericQ, 
   Cb0_?NumericQ, 
   te_] := (Model3[Vmax, Km, Fuc, Pdiff, Cb0] = 
    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, 45}, MaxSteps -> 100000, 
       PrecisionGoal -> \[Infinity]]]);

which contains Va and Vb. Then you fit

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 &)]

but this does not contain a Va or Vb. This cannot work. This is why in your file you get error messages like:

Part::partd: Part specification $Failed[[1]] is longer than depth of object. >> NonlinearModelFit::wtsnn: One or more weight values are not non-negative numbers. Weight values must be non-negative. >>

The fix is in the reply to your last post. Also I am not sure what you want to plot at the end. As Peter Fleck said, Plot[ListPlot ...] does not work. I suppose that you want to plot something like

Show[ListPlot3D[Dataimp], Plot3D[fit1[Cb0, te], {Cb0, 0, 30}, {te, 0, 45}]]

In the attached notebook, I have again (!) added Va and Vb just like the last time when you asked. The fit now (just like last time) fits a function, but it does not meet the criteria for the tolerances/precision and it also needs to use extrapolation. This is why you still get many error messages. Also because I fixed Va and Vb, the fit is not really good at all. It does, however, plot the two functions.

Cheers, Marco

Attachments:
POSTED BY: Marco Thiel
Posted 11 years ago

Jaydeep,

Plot[ListPlot[...],...] cannot work. I think you should probably take a close look at the syntax of Plot, ListPlot, and Show resp.

I would encourage you to simplify your problem as much as possible, if you still can't solve it, and post the simplest version of it here.

Best of luck, Peter

POSTED BY: Peter Fleck
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