Hot answers tagged

18

In this case I don't know how to post something helpful without providing full code so I'll just do that and hope this wasn't homework. My emphasis is on clarity (hopefully) rather than brevity or peak efficiency. flip = # /. {LightRed -> LightBlue, LightBlue -> LightRed} &; flipNeighbors[i_, j_] := (color[##] = flip @ color[##];) & @@@ ...


9

Edit Can you think of another way to accomplish the same thing [...]? It would be nice to have a solution that didn't involve duplicating each slider. -nibudd DynamicModule[{a = 1, tempA = 1, auto = True} , ifAuto = Dynamic[ If[auto, Identity, Setting]@#, TrackedSymbols :> {auto} ] &; Column[{ ifAuto @ Dynamic @ Plot[Sin[...


7

What is going on By default the Dynamic, EventHandlers and various controllers like Button and Slider use a PreemptiveLink to communicate with the kernel. Synchronous versus Asynchronous Dynamic Evaluations about the PreemptiveLink: [...] There is no queue; instead, the front end sends one evaluation at a time and waits for the result before ...


6

I think you should change your setup a little bit. Including procedures inside Dynamics is useful somethimes, for better events handling, but nothing fancy is going on here. Thus it is better schedule calculations in a more stable way, by moving the Grid generation outside Dynamic. Your exporting procedure clearly expects myplots to have an up to date ...


5

Your Manipulate expression works for me when I change your button specification to Button["Run", pts = {{0, 0}}; func[], Method -> "Queued"] However, I think it would better to replace your unnecessarily complicated Manipulate expression with a simple DynamicModule expression. DynamicModule[{pts = {{0, 0}}, a = 10, i = 1, func}, func[] := Do[Pause[....


3

Try this: Manipulate[myVal = N[Log[n]], {n, 2, 100, 1}] Dynamic@myVal myTab=Table[N[Log[n]], {n, 2, 100, 1}] {0.693147,1.09861,1.38629,1.60944,1.79176,1.94591,2.07944,2.19722,2.30259,2.3979,2.48491,2.56495,2.63906,2.70805,2.77259,2.83321,2.89037,2.94444,2.99573,3.04452,3.09104,3.13549,3.17805,3.21888,3.2581,3.29584,3.3322,3.3673,3.4012,3.43399,3....


3

The same way as you are showing the value for n. Dynamic is for displaying things. Evaluate Dynamic[N[Log[n]]. The output will be a display (not a value!) that dynamically updates whenever n is changed.


3

I use the tick method for all my demos and Manipulate. It works all the time and for all problems. It is based on the event callback method used in standard GUI frameworks. An event happens (such as moving a slider, or clicking a button) then a local action is performed, only based on that one event. Then the GUI is updated. This means no other action needs ...


3

Option 1: Use the UpdateInterval option to Dynamics, i.e., Dynamic[Plot[...],UpdateInterval->n,TrackedSymbols->{}] where n is measure in seconds. Here, UpdateInterval is how often Dynamic "manually" updates the expression. By default it will also update it any time one of the symbols is changed, so you also need to set TrackedSymbols->{}. ...


3

Things to keep in mind when developing complex GUI in Mathematica: Styles management/inheritance system (StyleSheets and friend) It is complicated, full of exceptions and only a tip of the iceberg is documented. Those 3 features are limiting the usage of it, which is a pity because it has a potential to give a lot. I'm also missing guidelines about common/...


3

Here's a quick mockup of what it sounds to me like you are attempting: DynamicModule[{iTabCount, iSelectedTab, tabSlider, tabUI}, iTabCount = 5; tabSlider[_] = 0; tabUI[i_] := Column[{ Slider[Dynamic @ tabSlider[i], {-1, 1}], Dynamic @ Plot[Sin[x + tabSlider[i]], {x, -2 Pi, 2 Pi}] }]; Column[{ Dynamic @ TabView[Array[...


3

Clear[η, a, b, s] η[r_, s_, a_, b_] := s (r^((1 - 3 b)/b) E^(-r/(a b))) Manipulate[ Plot[η[r, s, a, b], {r, 0, 10}, PlotRange -> All], {{s, 0.8}, 0, 1, Appearance -> "Labeled"}, {{a, 0.7}, 0.1, 1, Appearance -> "Labeled"}, {{b, 0.05}, 0.001, 0.1, Appearance -> "Labeled"} ] Regarding your original code, when you want to format/...


3

Here is the "nested Dynamic" approach the tutorial suggests. Dynamic Points special case You can't just put Dynamic in the ListPointPlot3D but you can in Graphics3D. Manipulate[Show[{ Plot3D[func[x, y], {x, 0, 2}, {y, 0, 2}, PlotPoints -> 50], Graphics3D[ {Green, PointSize[0.1], Dynamic@Point[pointsDgd3DOpt[[1 ;; nEndpoint]]]} ] ...


2

Here is an example with DynamicModule Example DynamicModule[ {data, sample, uLimit}, data = RandomReal[{-5, 5}, {1000, 3}]; sample = RandomSample[data, 300]; uLimit = 100; Column[{ Slider[Dynamic@uLimit, {1, 300, 1}, ContinuousAction -> False], Dynamic @ Show[{ ListPlot3D @ data, ListPointPlot3D[ sample[[;; uLimit]], ...


2

Regarding the lack of control of the output size, at least with a sufficiently high ImageResolution setting it can be tuned: test = Framed["TEST", Background -> Red, FrameStyle -> Blue, ImageSize -> {100, 100}, ContentPadding -> False] ImageDimensions[Rasterize[test, ImageResolution -> 354]]


2

Short answer: there is no equivalent of $ModuleNumber for DynamicModule. Authoritative comments by John Fultz (here and below) about the scoping of DynamicModule and how and why it is differing from the comparably simpler scoping of Module: [...] "this would require a concept of $ModuleNumber to be handled natively by the FE in the typesetting. Which ...


2

Though similar to @Jess's answer, I think this will work as you want. Dynamic[PLOT,UpdateInterval->10,TrackedSymbols->{}] Because UpdateInterval only set the Max Update interval!! So as your data is updating at a almost crazy speed, the plot will sense the change of your data and update crazily as well. You have to manually tell Dynamic: don't track ...


1

You could use a FileNameSetter to first select the file, then a button to import the data. For example: Manipulate[ DataModelGenerator[data1, Temperature, Rate, alphaseed, Qseed, Aseed,nseed], Row[{Item[FileNameSetter[Dynamic[selectedFile]], Alignment -> Center], Button["Import", data1 = Flatten[Import[selectedFile], 1]]}], {Temperature,...


1

I think second argument to Dynamic of InputField should help you. With it n is updated to the changed input and at the same time points are reinitialized. Help on input field says you can't use ContinuousAction with general expression, this is why Number type is specified. DynamicModule[{n = 2}, DynamicModule[{make, points}, make[n_Integer] := RandomReal[...


1

I don't consider the following terribly complicated, but you might hopefully pick something up from this: Graphics3D[{{Red, MapThread[{Text[Style[#2, Large, Bold], #1, {0, -1}], Arrow[Tube[{{0, 0, 0}, #1}]]} &, {IdentityMatrix[3], {"x", "y", "z"}}]}, With[{tr = Composition[...


1

There's no need for all this dynamic stuff, you can use Solve[] in conjunction with Manipulate[], and let Manipulate[] handle the dynamic stuff. Manipulate[ h = x /. Quiet@ Solve[2 == x*Cos[θ] - (p*x^2)/(6*c*d) (3 f + x) Sin[θ], x, Reals][[1]]; Show[{Graphics[{Opacity[0.5], Red, Rectangle[{1, 0}, {2, 1}]}, PlotRange -> {{-1, 2},...


1

Referring to the Manipulate documentation, you can change your sliders to input fields by going from control {x,0,10} to {x,0}. B = 2; Manipulate[ Show[{Graphics[{Opacity[0.5], Red, Rectangle[{1, 0}, {2, 1}]}, PlotRange -> {{-1, 2}, {-3, 3}}, Axes -> True, AxesOrigin -> {0, 0}], ParametricPlot[{x* Cos[\[Theta]] - (P*x^2)/(6*C*...


1

From my comment: Try Dynamic[valveType[p, scale, orientation, myCol], TrackedSymbols :> {myCol}] This worked for me and seemed to work for the OP, so I'll post it as an answer. One might normally expect an explanation, but the OP's code is rather too complicated (or at least long, at first glance) to really track down the problem quickly. I will ...



Only top voted, non community-wiki answers of a minimum length are eligible