The scrap of code below [from Mathematica's Help on DynamicModules
] generates a Pane
of Locator
s, and a line showing the interpolation between the datapoints.
DynamicModule[{pts = {{0, 0}, {1, 1}, {2, 0}, {3, 2}}},
LocatorPane[Dynamic[pts],
Dynamic[Plot[InterpolatingPolynomial[pts, x], {x, 0, 3},
PlotRange -> 3]
]]]
When the program is saved,and reloaded, the Plot
persists with the then current values of the points.
Suppose, after reloading the file (but not reinitializing the DynamicModule
), I want to use the values of the points (which I moved in interacting with the program before saving it). In otherwords, I'd like to be able to access a list of the modified points with, perhaps, new functions.
I realize I could just read out variables in the original function, store them, then load them as part of the initialization procedure when restarting a program a second time, but this in effect means running the original program history completely again. In complex programs, with lots of potential branches, this could be tedious and error prone.
Any solution? DynamicModule
would seem to attempt to address this problem by saving variables, but, for example, in the above code scrap, I want to get numerical values of the point positions for use in other parts of the program, how would I do it?
Answer
If I understand correctly, you can use Setting
:
Comments
Post a Comment