Mathematica: Processing Fit Parameters

data-fitting, design-patterns, rule, wolfram-mathematica

Solution

Well, you could write

x = a/.{a -> 1, b -> 2, c -> -3}

which will assign the value of `a` to `x`.

I'm not entirely sure that you should do this, you could simply store the list of rules in a variable and extract the bits from it as and when you want to.

Problem

I want to access the fit-parameters of a NonlinearModelFit. Here is the code ``` model = a*Cos[b*t + c]; fit = NonlinearModelFit[data, model, {a, b, c}, t, Method -> NMinimize] ``` When I use the command: ``` fit["BestFitParameters"] ``` the values are returned in the following format: ``` {a -> 1, b -> 2, c -> -3} ``` Now i want to store the value of a in a variable x ``` x=fit["BestFitParameters"][[1]] ``` but this gives ``` x= a -> 1 ``` No I want to know how I can resolve the "-> - Operator" to obtain ``` x=1 ``` Thanks in advance!

Original source