Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Data Fitting to Differential Equations' topicStudent Support Forum > General > "Data Fitting to Differential Equations"

Next Comment >Help | Reply To Topic
Author Comment/Response
Dr. Frank Solina Gilbert
09/28/05 6:01pm

Hi @all :),

First of all. I am a newbie in using mathematica. Please be patient.

I have developed a mathematical model in form of an differential equation for my task.
Now, I want to fit my data consisting of a set of 500 points (x1,x2,y). So I wrote the following code.

\!\(HSE[A_?NumberQ, B_?NumberQ, C_?NumberQ, D_?NumberQ] := Block[{sol,
f}, sol = \(NDSolve[{\((A + B\ Abs[f[t]] + C\
f[t]\^2 + D\ Abs[f[t]\^3])\)\ f[
t] + C\ \(f'\)[
t] == \ 0\ , f[0] == 0},
f, {t, 0,
500}, Method ->
"\<Automatic\>"]\)[\([1]\)]; Plus @@ \
Apply[\((f[#1] - #2)\)^2 &, data, {
1}] /. sol]; \ NMinimize[HSE[A, B, C, D], {A,
B, C, D}, \ Method -> "\<NelderMead\>"]\)



Solving this problem with a data set of 2 colums is not a problem, but I get an error message, if I use a data set with 3 colums like the following one:

ata = {{1.0,
0.014, 0.01}, {2.0, 1.4, 1.5}, {1.005,
2.1104, 4.44}, {8.0, 3.0, 0.144}, {.1, -.1, 0.114}};

I want to use the thirth colum as my vibration initiator. Then the code above becomes like this:


\!\(HSE[A_?NumberQ, B_?NumberQ, C_?NumberQ, D_?NumberQ] := Block[{sol,
f}, sol = \(NDSolve[{\((A + B\ Abs[f[t]] + C\
f[t]\^2 + D\ Abs[f[t]\^3])\)\ f[
t] + C\ \(f'\)[t] == \ g[t]\ , f[
0] == 0}, f, {t,
0, 500}, Method -> "\<Automatic\>"]\)[\([1]\)]; Plus \
@@ Apply[\((f[#1] - #2)\)^2 &, data, {1}] /. sol]; \
NMinimize[HSE[A, B, C, D], {A, B, C,
D}, \ Method -> "\<NelderMead\>"]\)


Mathematica says that the number of equations do no not match the number of parameters. I don't know waht to say, I am using Mathematica only since one week.

I would really appreatiate it, if someone could tell that I used a wrong syntax in my code.


Thnaks in advance, for your help.

Franc Solina Gilbert

URL: ,

Subject (listing for 'Data Fitting to Differential Equations')
Author Date Posted
Data Fitting to Differential Equations Dr. Frank So... 09/28/05 6:01pm
Re: Data Fitting to Differential Equations yehuda ben-s... 09/30/05 00:25am
Re: Data Fitting to Differential Equations Frank Solina... 09/30/05 4:12pm
Re: Data Fitting to Differential Equations Frank Solina... 10/01/05 08:26am
Re: Data Fitting to Differential Equations yehuda ben-s... 10/02/05 2:20pm
Re: Data Fitting to Differential Equations FRanc Solina... 10/05/05 4:48pm
Re: Data Fitting to Differential Equations Franc Solina... 10/13/05 09:12am
Next Comment >Help | Reply To Topic