Skip to main content
Tweeted twitter.com/#!/StackMma/status/406961665079803904
added 2 characters in body; edited title
Source Link
Sjoerd C. de Vries
  • 66.2k
  • 15
  • 189
  • 327

Append new simulation into CDF without resetingresetting current simulations

I need to duplicate a simulation inside one DynamicModuleDynamicModule. I believe It'sit's simpler to understand using an toy example. Here is the start screen:

enter image description here

Now if I play with a value, like this...

enter image description here

and then press Add button, I get:

enter image description here

with the first module resetedreset.

Someone know how can I preserve the Manipulate'sManipulate's states, when I Add or Remove an iten?

Here is my current code:

DynamicModule[{myCDF,controls,grid,btn},
    myCDF[]:=Manipulate[Plot[Sinc[a x],{x,0,10}],{{a,1},1,10}];
    grid={myCDF[]};
    btn["Add"]=Button["Add",AppendTo[grid,myCDF[]]];
    btn["Rem"]=Button["Remove",If[Length[grid]>1,grid=grid[[1;;-2]]]];

    controls=Grid[{{btn["Add"],btn["Rem"]}}];
    Dynamic@Panel[Column[{Grid[Transpose@{grid}],controls}]]
]

Append new simulation into CDF without reseting current simulations

I need to duplicate a simulation inside one DynamicModule. I believe It's simpler to understand using an toy example. Here is the start screen:

enter image description here

Now if I play with a value, like this...

enter image description here

and then press Add button, I get:

enter image description here

with the first module reseted.

Someone know how can I preserve the Manipulate's states, when I Add or Remove an iten?

Here is my current code:

DynamicModule[{myCDF,controls,grid,btn},
    myCDF[]:=Manipulate[Plot[Sinc[a x],{x,0,10}],{{a,1},1,10}];
    grid={myCDF[]};
    btn["Add"]=Button["Add",AppendTo[grid,myCDF[]]];
    btn["Rem"]=Button["Remove",If[Length[grid]>1,grid=grid[[1;;-2]]]];

    controls=Grid[{{btn["Add"],btn["Rem"]}}];
    Dynamic@Panel[Column[{Grid[Transpose@{grid}],controls}]]
]

Append new simulation into CDF without resetting current simulations

I need to duplicate a simulation inside one DynamicModule. I believe it's simpler to understand using an toy example. Here is the start screen:

enter image description here

Now if I play with a value, like this...

enter image description here

and then press Add button, I get:

enter image description here

with the first module reset.

Someone know how can I preserve the Manipulate's states, when I Add or Remove an iten?

Here is my current code:

DynamicModule[{myCDF,controls,grid,btn},
    myCDF[]:=Manipulate[Plot[Sinc[a x],{x,0,10}],{{a,1},1,10}];
    grid={myCDF[]};
    btn["Add"]=Button["Add",AppendTo[grid,myCDF[]]];
    btn["Rem"]=Button["Remove",If[Length[grid]>1,grid=grid[[1;;-2]]]];

    controls=Grid[{{btn["Add"],btn["Rem"]}}];
    Dynamic@Panel[Column[{Grid[Transpose@{grid}],controls}]]
]
Source Link
Murta
  • 26.4k
  • 6
  • 77
  • 168

Append new simulation into CDF without reseting current simulations

I need to duplicate a simulation inside one DynamicModule. I believe It's simpler to understand using an toy example. Here is the start screen:

enter image description here

Now if I play with a value, like this...

enter image description here

and then press Add button, I get:

enter image description here

with the first module reseted.

Someone know how can I preserve the Manipulate's states, when I Add or Remove an iten?

Here is my current code:

DynamicModule[{myCDF,controls,grid,btn},
    myCDF[]:=Manipulate[Plot[Sinc[a x],{x,0,10}],{{a,1},1,10}];
    grid={myCDF[]};
    btn["Add"]=Button["Add",AppendTo[grid,myCDF[]]];
    btn["Rem"]=Button["Remove",If[Length[grid]>1,grid=grid[[1;;-2]]]];

    controls=Grid[{{btn["Add"],btn["Rem"]}}];
    Dynamic@Panel[Column[{Grid[Transpose@{grid}],controls}]]
]