Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Student Support Forum
-----
Student Support Forum: 'Data fitting for 2 differential equations' topicStudent Support Forum > General > Archives > "Data fitting for 2 differential equations"

< Previous CommentHelp | Reply To Comment | Reply To Topic | Post New Topic
Author Comment/Response
Matt
05/18/08 9:01pm

Hi,

I had worked on the problem but I'm having issues with how to make the model, i.e.

I can generate a sample data by following the example:
{xsol, ysol} =
First[{x, y} /.
NDSolve[{ x'[t] == 1. x[t] - 2. x[t] y[t], x[0] == 1,
y'[t] == -1. y[t] + 1. y[t] x[t], y[0] == 2}, {x, y}, {t,
20}]];
times = N[Range[0, 100]/5];
xdata = Transpose[{times, xsol[times] + RandomReal[.1, 101]}];
ydata = Transpose[{times, ysol[times] + RandomReal[.1, 101]}];
data = Table[{times[[i]], xdata[[i, 2]], ydata[[i, 2]]}, {i, 1,
Length[times]}];
lp = ListPlot[{xdata, ydata}, PlotRange -> All]


However I'm having difficulty instantating the different models for each of the variable (i.e. x[t] and y[t]). If I tried to just instantiate x[t], i.e.:
xmodel[a_?NumberQ, b_?NumberQ, c_?NumberQ,
d_?NumberQ] := (xmodel[a, b, c, d] =
First[x /.
NDSolve[{ x'[t] == a x[t] - b x[t] y[t], x[0] == 1,
y'[t] == c y[t] + d y[t] x[t], y[0] == 2}, {x, y}, {t, 20}]])

and fit the data on this model:
fit = FindFit[data, xmodel[a, b, c, d][t], {a, b, c, d}, {x, y, t},
PrecisionGoal -> 4, AccuracyGoal -> 4], I get errors:
FindFit::fitc: Number of coordinates (2) is not equal to the number \
of variables (3). >>

I think I had this messed-up. I'm a Mathematica newbie and would appreciate guidance.

Thanks again for all the help.

Best regards.

URL: ,

Subject (listing for 'Data fitting for 2 differential equations')
Author Date Posted
Data fitting for 2 differential equations Matthew 05/12/08 4:22pm
Re: Data fitting for 2 differential equations Matt 05/18/08 9:01pm
< Previous CommentHelp | Reply To Comment | Reply To Topic | Post New Topic





 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy