Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14074

Re: Problem with function definition inside DynamicModule

From debguy <johnandsara2@cox.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Problem with function definition inside DynamicModule
Date 2013-04-05 02:29 +0000
Message-ID <kjlcuu$b60$1@smc.vnet.net> (permalink)
References <kjkc64$7n6$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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.

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Problem with function definition inside DynamicModule "Kevin J. McCann" <kjm@KevinMcCann.com> - 2013-04-04 17:10 +0000
  Re: Problem with function definition inside DynamicModule debguy <johnandsara2@cox.net> - 2013-04-05 02:29 +0000
  Re: Problem with function definition inside DynamicModule debguy <johnandsara2@cox.net> - 2013-04-05 02:29 +0000

csiph-web