Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Questions relating to the dynamic family of functions in Mathematica, such as Dynamic, DynamicModule and Manipulate.
12
votes
Accepted
Problem with UpdateInterval
When you edit ls, all dynamics that depend on ls will update instantly, this will cause ls to be edited which will update the dynamic which edits ls.... etc. … The way to avoid this is to specify that there should be no tracked symbols:
Dynamic[Refresh[AppendTo[ls, k++];
Last@ls, UpdateInterval -> 10], TrackedSymbols -> {}] …
12
votes
Accepted
Generating dynamic Inputfields
This page in the section "Nesting Dynamic" is a good read about a situation in which this trick is also used. However there it is used to avoid unwanted dynamic updates. … The thing is that Dynamic has the attribute HoldFirst
Attributes[Dynamic]
{HoldFirst, Protected, ReadProtected}
This means the first argument given to it is held in place, consider for example …
8
votes
Accepted
Simple blink comparator for two images
You need to assign imageList for it to actually update, also you need to make the graphics dynamic for it to update when the list is changed. … EventHandler[Dynamic@Show[First[ ... …
1
vote
Accepted
Dynamic Updating CreateDialog Problem
I'm not sure if this fully answers your question, but here is a method of using the Dynamic to check if a dialog is already open and reopen it if it has been closed:
DynamicModule[{nb = CreateDialog[Dynamic … @y]},
TogglerBar[
Dynamic[y, (y = #;If[Not@MemberQ[Notebooks[], nb],nb = CreateDialog[Dynamic@y]]) &],
Range[5]]] …
1
vote
Using Button to display dynamic graphics
If I understand you correctly, you can simply display h in a Dynamic and then create your button to increase k, so first define your module:
k = 1;
h := Plot[Sin[k*x], {x, 0, 10}]
Then display the plot … and button:
Button["Increase k", k = k + 1]
Dynamic[h] …
2
votes
Accepted
Interaction between two sliders that update the same variable
You can simply get what you are expecting by also including the snap functionality in the dynamically displayed value through:
DynamicModule[{x = 0},
Column@{Slider[
Dynamic[If[Abs[x- Round[x]] < 0.3 … , Round[x], x],
If[Abs[# - Round[#]] < 0.3, x = Round[x], x = #] &], {0, 5}]
, Slider[Dynamic[x], {0, 5}]
, Dynamic[x]
}] …
7
votes
Accepted
How can I allow a user to input a list using parentheses and convert this to Mathematica not...
Since that returns a dynamic slider, you wold think that your function f[a_,b_]:=a+b would return a dynamicly updated value if you just ran: f[Dynamic[v1], Dynamic[v2]]. … For this example, you would have needed to express how f should handle a dynamic, and could have used: f[Dynamic[a_], Dynamic[b_]] := Dynamic[a + b], which would then work in the way expected above. …
2
votes
Accepted
How to compare the InputField values in For loop dynamically
Also you missed a Dynamic in the inputfield:
tx = {4, 1, 6, 7, 8};
yourLoop=Reap[For[i = 1, i <= 5, i++,
With[{i = i},
Sow[{
InputField[Dynamic[tx[[i]]]],
Dynamic[If … [(tx[[i]] < 10), "right", "wrong"]]
}]
]
]];
yourLoop[[2, 1]] // Grid //Panel
There's some more details about the With[{i=i}] solution in my answer to the question Generating dynamic …
8
votes
Accepted
Dynamic lists as function arguments
In you first definition everything goes as you expect:
g[point_] := Slider2D[point]
g[Dynamic[p]] = (* Becomes => Slider2D[Dynamic[p]] *)
But in the second case you are stripping away the Dynamic … Dynamic[var_] :> Dynamic[var[[1]]]]
p = {.1, .1}
g[Dynamic[p]]
Dynamic[p]
Though I would personally define this as:
g[Dynamic[point_]] := Slider[Dynamic[point[[1]]]]
Simply to make it clear that I'm …
2
votes
how to dynamically change color of setterbar
What you can then do is to simply write the code for you setter bar:
SetterBar[Dynamic[x], Range[3], AutoAction -> True, Appearance -> None]
And then slightly change the value specification. … So then you could add a dynamic panel which changes color to red if it's value is equal to the selected value:
turnRed[n_] := (n -> Dynamic@Panel[n, Background -> If[x == n, Red, White]])
SetterBar[ …
3
votes
help with dynamic input
Put With[{i=i}] to get the indexing in the dynamic right:
a = Table[List[
StringJoin[{"Number of neurons in layer ", ToString[i], ":"}],
With[{i = i}, InputField[Dynamic[d[i]], Number]]], {i, 3}];
AppendTo … I have added some more details on why this problem occurs, and why the solution works to a previous related question: Generating dynamic Inputfields …
2
votes
How to create Locator[] hierarchies?
level:
SetAttributes[updateTree, HoldFirst]
updateTree[tree_, newposition_, indices__] :=
tree[[indices]] = Map[# + (newposition - tree[[indices, 1]]) &, tree[[indices]], {-2}];
Then I define a new dynamic … SetAttributes[treeDynamic, HoldAll]
treeDynamic[tree_[[indices__]]] := Dynamic[tree[[indices]]]
treeDynamic[tree_[[indices__, 1]]] :=
Dynamic[tree[[indices, 1]], updateTree[tree, #, indices …
3
votes
Is it possible to replicate the "magic" of OptionPatterns[] with DynamicModule's local varia...
then pass it through as an argument to a function, you can also just not have any function at all:
Component1 := Button["Increase x", x++];
Component2 := Button["Decrease y", y--];
Component3 := {Dynamic … @x, Dynamic@y};
DynamicModule[{x = 1, y = 2},
Row[{Component1, Component2, Component3}]
] …
4
votes
Accepted
How to get the associated popup menu?
The first part of your question can be done very simply by making dynamic popupmenues where the options are related to the choices of the other popupmenues:
PopupMenu[Dynamic[varA], {a, b}]
Dynamic[ … PopupMenu[Dynamic[varB], Switch[varA, a, {c, d, e}, b, {f}, _, {}]]]
Dynamic[PopupMenu[Dynamic[varC], Switch[varB, c, {g, h}, _, {"So on"}]]]
Hopefully someone else will be able to help with the best …
9
votes
Accepted
Using more than one set of Locators in a Manipulate
I know this doesn't answer the question of the buggy behavior, but I would suggest an implementation without using Manipulate:
DynamicModule[{pt = {}, pt2 = {}},
Column[{
Graphics[{
Dynamic … @MapIndexed[With[{i = #2[[1]]}, Locator[Dynamic[pt[[i]]], Appearance -> Small]] &, pt],
Dynamic@MapIndexed[With[{i = #2[[1]]}, Locator[Dynamic[pt2[[i]]], Appearance -> Large]] &, pt2]
}, PlotRange …