I want to fit a gaussian profile by setting some values dynamically, but FindFit
returns an error and i can't see the problem.
with a given gaussian:
gauss = Table[{x,
E^(-((x - 10)^2/(2 3^2))) + RandomReal[{-0.05, 0.05}]}, {x, 0, 20,
0.05}];
I set the model to:
gaussmodel = b Exp[-((x - d)^2/(2 g^2))];
With fitparameters set non-dynamically everything is fine:
fit = FindFit[gauss, gaussmodel, {{b, 1}, {d, 10}, {g, 3}}, x]
(*{b -> 1.00439, d -> 10.0109, g -> 2.9804}*)
Now I want to set the startingvalues as following:
InputField[Dynamic[startvalueb], Number]
InputField[Dynamic[startvalued], Number]
InputField[Dynamic[startvalueg], Number]
Checkbox[Dynamic[bool1]]
xx0 = {Dynamic[
Which[bool1 == True, {b, Dynamic[startvalueb]}, bool1 == False,
Null]], Dynamic[
Which[bool1 == True, {d, Dynamic[startvalued]}, bool1 == False,
Null]], Dynamic[
Which[bool1 == True, {g, Dynamic[startvalueg]}, bool1 == False,
Null]]}
witch returns just the form I need, but maybe not??!? Anyway
fi2 = FindFit[gauss, gaussmodel, xx0, x]
returns the following error:
FindFit::vloc:The variable {b,1} cannot be localized so that it can be assigned to numerical values.>>
What can I do to fix this?