New answers tagged

4

tl;dr; Use SynchronousInitialization -> False and, in case of simple Dynamic[x], add TrackedSymbols: Dynamic[x, TrackedSymbols :> {x}] due to the bug mentioned below. Finally I'm able to answer my question with understanding. Two years, no big deal :) So I want Dynamic[x] to reflect the state of the initialization. The last example in WReach's ...


2

There may be a confusion about what Dynamic is follow those links please: Programming with Dynamic Why won't this work? Dynamic in a Select IntroductionToDynamic Now, this should be more flexible approach, pass a symbol to Preplot, treat Preplot as a controller. I think it is also a more idiomatic approach. ClearAll@Preplot; SetAttributes[Preplot, ...


3

This should give you a starting point: opt = {PlotStyle -> Orange, AxesLabel -> {"\[Mu]s", "V"}, ImageSize -> 300} Manipulate[ Plot[Sin[10/x], {x, 0, 5}, PlotRange -> {xInt, {vMin, vMax}}, Evaluate[opt]], {{vMax, 0}, -1, 1, VerticalSlider, Appearance -> "Labeled"}, {{vMin, -1}, -1, 1, VerticalSlider, Appearance -> "Labeled"}, {{xInt,...


2

Building on Kubas code here is an alternative which solves some (minor) problems: it will not leave behind scheduled tasks when the abort button is used, it works equaly well when the Alt-. shortcut is used to abort and it might work better when aborting preemptive evaluations. Here is the code: SetAttributes[withProgressIndicator, HoldFirst]; ...


4

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[...


10

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[...


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

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/...


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[##];) & @@@ ...


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 ...


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 ...


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[...


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]], ...


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 ...


0

I got a reply from Wolfram Technical Support. It turns out the slow response was caused by not localizing the variables ax and by inside the Module statements. The MouseDown was triggering their update, which in turn caused the whole graphic to be recreated. Thanks to John Fultz. I am told the only way to track down unexpected dependencies is by selectively ...


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 ...


0

Got everything working the way I want it to. Here is the code below if anyone ever wants to model a cantilever bending on a box. Manipulate[h = x /. Quiet@Solve[k == x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]], x, Reals][[1]]; a = x /.Quiet@Solve[l == x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]], x, Reals][[1]]; b = a*Sin[\[...


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*...


0

Upgrading to a newer computer solved the problem. Perhaps it was RAM- or grpahics-card-related, we'll never know.


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 ...


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.


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[...



Top 50 recent answers are included