Fitting integral of complicated function into a dataset

So, I'm trying to adjust a model to an experiment, this model, more specifically:

While:

The only parameter to be adjusted is I, the problem here is, I not only need to plot this with all the errors and so, as I need to fit the integral of this in respect of "r" from 0 to 2*pi, with "d" being the x-axis value.

I'm extremely new to Mathematica, I've been barely able to just plot the data points with errors, without any fitting whatsoever, how should I proceed? And, is it feasible at all?

Oh,and E_1/E_2 are complete elliptic integrals of first and second kind, respectively…

Edit: This is my current code, however it doesn't wields me more than a bunch of warnings and errors, and, this is the actual model implemented:

• Can you post the data as well? Dec 1 '17 at 11:29
• Of course!.And, this is the code I've been (trying to) working in, in the last hours. Dec 1 '17 at 11:31
• In your code Sqrt[_] (like all functions) must use square brackets rather than parentheses. And the call to the function field must include its arguments. Dec 1 '17 at 13:50
• @BobHanlon Oh, Thank you! Such a simple problem… C++ Habits… However, I have a new problem, here's my current code, now it gives me "FindFit::fitm: Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted.", and I don't really know what it means. Dec 1 '17 at 17:04
• New updated current version…, I'm still not sure what the problem may be, I've tried all the suggestions I could find, and, yet, nothing… Dec 1 '17 at 18:11

The data then consists of lists of pairs of numbers rather than a string.

Union[{Head[#], Length[#], And @@ (NumberQ /@ #)} & /@ data]

(* {{List, 2, True}} *)

(* mu=4 e-7*Pi *)

mu = 4*10^-7 * Pi; (* Assuming you intended this *)
frequency = 8313 // Rationalize;

There is no need to restrict the arguments of field to be numeric since it does not use numeric techniques.

field[r_, x_, mu_, Radius_, frequency_] :=
mu*frequency*
Sqrt/(2*Pi*

However, define the model using NIntegrate which then necessitates that the arguments to model be numeric. Note that i must also be an argument and the integrand should not be enclosed in List brackets.

Clear[model]

frequency_?NumericQ] :=

solution = FindFit[data, model[i, x, mu, Radius, frequency], {{i, 0.7}}, x]

(* {i -> 12.7577} *)

{xmin, xmax} = MinMax[data[[All, 1]]];

However, the model does not appear to fit the data.

Plot[model[i, x, mu, Radius, frequency] /. solution,
{x, xmin, xmax},
Epilog -> {Red, AbsolutePointSize, Point[data]}] NonlinearModelFit produces the same results.

nlm = NonlinearModelFit[data, model[i, x, mu, Radius, frequency], {{i, 0.7}},
x];

nlm["BestFitParameters"]

(* {i -> 12.7577} *)

Plot[nlm[x], {x, xmin, xmax},
Epilog -> {Red, AbsolutePointSize, Point[data]}] 