MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problems in fitting the experimental data with the expression

On 5/16/09 at 5:19 AM, umamaheswari1973 at wrote:

<snip data>

>fw[w_?NumericQ, L_?NumericQ] :=
>NIntegrate[ 4*Pi*q^2*Exp[-(L^2*q^2)/(16* Pi^2)]/((w - (520 -
>(120*(q/1.15712)^2)))^2 + (3.5/2)^2), {q, a, b}]

>I want to  fit the value of L.

>w : values are taken from the x-data of the experiment.

>FindFit[ay, fw[w, L], {L}, {ax[[1]], ax[[84]]}]

>I got the error as

>General::ivar: 600.58` is not a valid variable. >>

The reason you are getting this error is you are not using
FindFit correctly.

The the basic syntax for FindFit is as follows:

FindFit[data, model, parameters, variables]

data needs to be a matrix with the dependent variable in the
right most column. For your particular case. Setting data to
Transpose@{ax,ay} will satisfy this requirement.

the model needs to be an expression relating the independent
variables to the dependent variable. For example, if you were
doing a simple linear fit, this would be m x + b.

parameters is a list of the unknown parameters in the model. For
the linear model above, the parameters are {m,b}

Finally, variables is a list of the independent variables in the
model. For the linear model above, this would be x. This list
needs to be a list of symbols and should have n-1 members where
n is the number of columns in data. You have failed to meet
either of these requirements since you are supplying a list of
two real numbers for the variables. This is the source of the error.

Notice 600.58 is the first value in ax. You simply cannot use
this as a variable.

So, correct syntax would be

FindFit[Transpose@{ax,ay}, fw[w, L], {L}, {w}]

However, while this will correct the specific error you got from
FindFit, it will not solve your problem. The function you wrote
fw will not work as written. In that function you have specified
the limits of integration as a,b and nowhere defined a or b.
Consequently, NIntegrate cannot work since it needs numeric
integration limits.

  • Prev by Date: Re: Weird palette stuff, still learning...Help!
  • Next by Date: How to resize elements in GraphicsGrid
  • Previous by thread: Problems in fitting the experimental data with the expression
  • Next by thread: How to resize elements in GraphicsGrid