I would like to create a notebook with a demonstration:
SlopeInterceptDemonstration[{mmin_, mmax_}, {bmin_, bmax_}] :=
Module[{xmax, xmin},
xmax = Max[Abs[bmin + mmin], Abs[bmax + mmax]]*1.2;
xmin = - xmax;
Manipulate[
Plot[m*x + b, {x, xmin, xmax}, AspectRatio -> 1, PlotRange -> {xmin, xmax}],
{{m, mmin, "m"}, mmin, mmax, 0.1}, {{b, bmin, "b"}, bmin, bmax, 0.1}]
];
If I save a notebook with a simple call ( SlopeInterceptDemonstration[{-2, 2}, {-5, 5}] ) evaluated and reopen it with a fresh kernel the demo is not displayed because xmin and xmax are not known.
Is there a way force the evaluation of these variables inside Plot?
You can use
DynamicModuletogether with theSaveDefinitionsoption inManipulate: