MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problem with function definition inside DynamicModule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130358] Re: Problem with function definition inside DynamicModule
  • From: debguy <johnandsara2 at cox.net>
  • Date: Thu, 4 Apr 2013 22:31:36 -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>

datafit[]:= DynamicModule[{n},
   Panel[
    Column[
     {
      Row[{"n", Spacer[5], SetterBar[Dynamic[n], Range[5]]}],
      Dynamic@
       Plot[ Fit[dat, Table[x^k, {k, 0, n}], x], {x, 0, 5},
        Epilog -> ListPlot[dat, Joined -> False,
            PlotStyle -> {Red, AbsolutePointSize[7]}, PlotRange -> All]
[[1]],
        PlotLabel -> "n = " <> ToString[n],
        PlotRange -> {0, 30}]
      }
     ](*Column*)
    ](*Panel*)
   ];(*DynamicModule*)

datafit[];
dataupdate[x_]:=dat=x;
dataupdate[somedat];

I think the above will update if ever and when:

    Global`dat changes  or  Slider's n changes

And I cannot test it though.

But notice I didn't make dat internal to DynamicModule because there
is no intended Slider inside datafit that would create itself within
the scope of DynamicModule to change dat inside the DynamicModule (the
right dat).  I didn't use datafit[ dat_] since (a protected symbol dat
local to a function / arg) maybe Dynamic cannot track assignments to
(or from) or will track strangely.



  • Prev by Date: Re: Problem with function definition inside DynamicModule
  • Next by Date: Re: extract from Reduce
  • Previous by thread: Re: Problem with function definition inside DynamicModule
  • Next by thread: Re: Problem with function definition inside DynamicModule