Re: Problem with function definition inside DynamicModule
- To: mathgroup at smc.vnet.net
- Subject: [mg130357] Re: Problem with function definition inside DynamicModule
- From: debguy <johnandsara2 at cox.net>
- Date: Thu, 4 Apr 2013 22:31:15 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <kjkc64$7n6$1@smc.vnet.net>
I have don't have Dynamic to test with in my version, but this might help. I think Dynamic@Plot[f[x], {x, 0, 5}, Epilog -> p1[[1]] should update if p1 changes but not x. "f" is a question. I think you said it does but f[x] does not. Try this: f[x_, y_] = Fit[y, Table[x^k, {k, 0, n}], x]; This definition doesn't bury dat inside f. This may insure Dynamic chooses the new f. Also I'm thinking to update plot automatically when dat changes you want to define datafit to use Dynamic[dat] rather than using dat as a parameter. That might be a simpler approach. Having used Dynamic[dat] in datafit you can then have your update by parameter with simply: datafitupdate[x_]:=dat=x;