Re: how uncouple dynamic objects?
- To: mathgroup at smc.vnet.net
- Subject: [mg109444] Re: how uncouple dynamic objects?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Tue, 27 Apr 2010 07:41:06 -0400 (EDT)
- References: <hr65qt$jp8$1@smc.vnet.net>
Am 27.04.2010 10:04, schrieb Murray Eisenberg: > Here's a simple example of a more complicated situation where I define a > function that takes a function as argument and uses Manipulate to > produce its output: > > fplot[f_]:= Manipulate[ > Plot[f[x+a],{x,-2,2}], > {a,0,2}] > f[x_]:= x^2 > fplot[f] > > f[x_]:=x^3 > fplot[f] > > When I execute the second definition (with x^3) of f, it automatically > changes the f used in the still-displayed output from the first call to > fplot. > > How can I isolate the two instances -- and yet still use the same name > for the two different functions? (Or is this not possible?) Manipulate knows the TrackedSymbols-Option, if you put in everything that needs to be tracked except for f it will behave as you require: fplot[f_] := Manipulate[Plot[f[x + a], {x, -2, 2}], {a, 0, 2}, TrackedSymbols :> {a}] It will isolate in the sense that the Manipulate just doesn't realize it is still using an old definition of f. I can't say whether that will cause problems or will isolate the two definition in every situation but for your example it seems to work... > Clearly this is an issue of the dynamic structure underlying > Manipulate, and I'm willing to use a "direct" definition using a > Dynmaic variable a with a control instead of the simpler > Manipulate. But of course I'd prefer to be able to do it with > Manipulate. > hth, albert