# Nonlinear model fit output [closed]

I'm trying to fit my data to function A.

z = 50;
s[x_] == (((q^2 (x/wr - wr/x)^2 + (z/(2 r) + 1))/(q^2 (x/wr - wr/x)^2 + (z/(2 r) + 1)^2))^2 + ((
q (x/wr - wr/x) (z/(2 r)))/(
q^2 (x/wr - wr/x)^2 + (z/(2 r) + 1)^2))^2)^(1/2);
A[x_] == 20*Log10[s[x]];

nlm = NonlinearModelFit[
data, {A[x], q > 0, wr > 0,
r > 0}, {{q, 9000}, {wr, 42000000}, {r, 0.1}}, x][
"BestFitParameters"]
Show[Plot[nlm, {x, 41000000, 43000000}, AspectRatio -> Full,
PlotRange -> {{4.19*10^7, 4.25*10^7}, {0, -55}}],
ListPlot[data[[All, {1, 2}]], PlotRange -> All, PlotStyle -> Red]]


but for my output I get the following:

I'm not sure what the problem is and why I don't get any values for my fit parameters.

## closed as off-topic by Bob Hanlon, JimB, Coolwater, LLlAMnYP, m_goldbergMay 16 '18 at 14:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, JimB, Coolwater, LLlAMnYP, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Chris K May 16 '18 at 1:06
• You should replace the == in A[x_] == 20*Log10[s[x]]; with a single = (and follow @BobHanlon 's advice below. – JimB May 16 '18 at 2:26

You have defined nlm as rules for the parameters rather than the model

data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}, {6, 4}, {7, 5}};

nlm = NonlinearModelFit[data, Log[a + b x^2], {a, b}, x]["BestFitParameters"]

(* {a -> 1.50632, b -> 1.42633} *)


Whereas, if you use parentheses to isolate the definition of the model

(nlm = NonlinearModelFit[data, Log[a + b x^2], {a, b},
x])["BestFitParameters"]

(* {a -> 1.50632, b -> 1.42633} *)

Plot[nlm[x], {x, Min[data[[All, 1]]], Max[data[[All, 1]]]},
Epilog -> {Red, AbsolutePointSize[4], Point[data]}]


• Hey Bob, even when I make that change I get the same output! – user171881 May 16 '18 at 2:01
• Did you change the argument to Plot to nlm[x] as shown? – Bob Hanlon May 16 '18 at 2:12
• @BobHanlon I think the error occurs because of the use of == in A[x_] == 20*Log10[s[x]];. But I agree about the issue you found with the assignment of nlm. – JimB May 16 '18 at 2:21
• @JimB - since the OP did not provide data, I was not able to run the code and did not notice the improper definitions of both A and s. – Bob Hanlon May 16 '18 at 2:28