I am trying to create a visual aid for peak fitting. There should be a background profile and on top, I want to place peaks. So far, I am stuck with the following issue. For simplicity, I am using a gaussian and two peaks. I have:
\[Mu]dμd = {5422.6501499999995`, 6450.7998`, 6711.8498500000005`,
6824.2998`, 8795.4004`, 9502.0996`};
{t0, t1} = {4690.5`, 11110.5`};
The following code works as intended (I manipulate the sigmas as I wish):
ClearAll[model0]
model0 =
Exp[-((t - \[Mu]d[[1]]μd[[1]])^2/(2 \[Sigma]1^2σ1^2))] +
Exp[-((t - \[Mu]d[[2]]μd[[2]])^2/(2 \[Sigma]2^2σ2^2))];
With[
{localmodel = model0 /.
{\[Sigma]1σ1 -> \[Sigma]v1σv1, \[Sigma]2σ2 -> \[Sigma]v2σv2}},
Manipulate[
Quiet@Plot[localmodel, {t, t0, t1}, PlotRange -> Full],
{{\[Sigma]v1σv1, 100}, 0.01, t1 - t0},
{{\[Sigma]v2σv2, 100}, 0.01,
t1 - t0}
]
]
Since, I am planning to have more peaks in the model, the above will become soon cumbersome and iI was hoping to simplify things by defining the model compactly but the approach below is not working (I have never understood how Mathematica interprets subscripts):
model1 =
Sum[Exp[-((t - \[Mu]d[[i]]μd[[i]])^2/(2 Subscript[\[Sigma]Subscript[σ, i]^2))], {i, 1,
2}]
With[
{localmodel = model1 /.
{\[Sigma]σ -> \[Sigma]vσv}
},
Manipulate[
Show[
Plot[model1[t, \[Sigma]]σ], {t, t0, t1}, PlotRange -> Full],
],
{{Subscript[\[Sigma]vSubscript[σv, 1], 1000}, 0.01,
t1 - t0},
{{Subscript[\[Sigma]vSubscript[σv, 2], 1000}, 0.01, t1 - t0}
]
]
How should I go about this so that I can define things compactly, ideally also in the Manipulate
variables?