Tag Info

Hot answers tagged

11

I prefer Bold and Larger in Style: Animate[ Grid[ Partition[ Table[ Style[i, Bold, Larger, If[i > j, Black, If[ PrimeQ @ i, Blue, Gray]]], {i, 100}], 10], Spacings -> {1, 1}], {j, 0, 100}, Paneled -> False] but if you like delete from ...


11

One way is to create a Polygon and transform the vertices under the flow. I used NDSolve to solve the flow for initial points in a square containing the OP's disk. Then I made a listable Function that can be applied to a the vertices of the polygon. Since only the flow depends on the time t, I used a GraphicsComplex so that the vertices come first as a ...


10

Here's a fairly simple way to fix your Manipulate by applying Dynamic to ListPlot. Manipulate[ (* Beep[]; *) data = function @ Range[-Pi*10., Pi*10, Pi/1000]; Dynamic @ ListPlot[data, PlotRange -> {{start, stop}, Automatic}], {function, {Sin, Cos, Tan}}, {start, 1, Length[data]}, {{stop, 300}, 1, Length[data]}, {data, ControlType -> None}] ...


10

Thanks to Michael E2's comment, the following approach is successful. The method sets up a scheduled task that (at certain resolution res) monitors the elapsed $time and compares it to the dynamic $max. If $time is more than allowed by $max, it calls the front-end "EvaluatorAbort". Attributes[dynamicTimeConstrained] = {HoldAll}; ...


10

Dynamic has this build into it. You can take advantage of the Dynamic second and third arguments. The second argument of evaluate as the dynamic is being updated. The third argument is evaluated when the mouse is released. Which is what you want. To illustrate, here is an example, where f[r] and g[r] are inside the arguments of the slider itself. This is ...


9

A direct replacement Perhaps your specific example might best be handled with: Array[ (a[##] = f[##]) &, Table[4, {3}] ] { . . . { . . . {f[3, 1, 1], f[3, 1, 2], f[3, 1, 3], f[3, 1, 4]} . . . } . . . } Where 4 is n and 3 is the number of loops. Output it was included above for illustration; it may be suppressed with CompoundExpression: ...


9

I would approach this problem a bit differently. I would provide each such notebook with an initialization button at its top, right under its title, if any. By pressing this button, the dynamic apdating would be enabled. How to do it technically, is already in the comment of belisarius. The further is only a question of a design. The latter should be ...


9

ControlActive is useful for this purpose: DynamicModule[{r = 1, old = 1} , Grid[ { {Slider[Dynamic[r]], SpanFromLeft} , {Dynamic[f[r]], Dynamic[g[ControlActive[r, old = r]; old]]} } ] ] The variable old has been introduced to hold the "old" value of r. The key expression is ControlActive[r, old = r]; old, which always returns the value of ...


8

Yes, it is a bug. I am quite confident it will be fixed in an upcoming release.


8

Artes's answer is just fine. This variation works as follows. When you click on a number, the background of that number turns yellow and that of each of its divisors turns light blue. DynamicModule[{s = 101}, Grid[Partition[Dynamic@Button[Style[#, 16], (s = #), Background -> Which[ # == s, Yellow, Divisible[s, #], LightBlue, True, White], Appearance ...


8

Note that you've defined t as a Dynamic expression. A relational operator like GreaterEqual (>=) works with numeric expressions like the result of Clock. You could try something like this to get a displayed output that eventually switches from False to True: step = .1; Dynamic[{t, t = Clock[{0., 5., step}, 5., 1]; t >= 2}]


7

In such cases, you can get better flexibility by switching to a DynamicModule and building up the GUI yourself. Then, you can pull the data generating step out of the plotting dynamic, so that the latter can be manipulated freely without regenerating the data. DynamicModule[{function = Sin, start, stop = 300, x = Range[-10 Pi, 10 Pi, Pi/100]}, ...


7

This is good reason to use the second argument of dynamics. Manipulate[ function; (*just to allow tracking, since not explicity in the command*) ListLinePlot[data, PlotRange -> {{start, stop}, Automatic}, ImageSize -> 300, ImagePadding -> 30, Frame -> True, FrameLabel -> {{None, None}, {"x", function}} ], Grid[ { ...


7

I believe that Mathematica feeds the input string in free-form linguistic input to the function WolframAlpha. Try something like Manipulate[ If[in =!= "", WolframAlpha[in], "Enter input"], {{in, ""}, InputField[Dynamic[in], String] &} ] Response to comment I can't find a definitive statement in the documentation that an internet connection is ...


7

Here's a trivial example of the method in my comment. I've used total absolute difference for error (you can use whatever you please), and I put in a Pause so you can observe the effect for this trivial problem that would be blink-of-an-eye fast. In reality, you'd want to use UpdateInterval or equivalent, or Sow if you want the "history" post-run. Doing ...


6

This should work: rows = 3; cols = 4; data = RandomInteger[{1, 100}, {rows, cols}]; names = {"First", "Second", "Third", "Fourth"}; sortBy[data_, idx_] := If[idx == 0, data, Sort[data, #1[[idx]] < #2[[idx]] &]]; Dynamic@Grid@Prepend[data, Array[Button[names[[#]], data = sortBy[data, #]] &, cols]]


6

This can be achieved by adding the ControllerLinking -> False option to any Graphics3D objects that you do not wish to be affected by the external controller. For example with Manipulate[ Graphics3D[{FaceForm[Hue[x]], Cuboid[]}, ControllerLinking -> False], {x, 0, 1}] my joystick x-axis changes the colour but the cube doesn't rotate.


6

What I really wanted to post was an alternative way of generating the grid. In my humble opinion, it's better to do it with Table without Partition as it looks better in code. But since Animate has already been dealt with, three times over, let me also use an alternative method for that: color[n_] := Style[n, Which[100 Clock[1, 10] < n, Black, PrimeQ@n, ...


6

Expanding a little over rasher's answer: data = Table[{x, Log[3.5 + 2.5 x^2] + RandomReal[{-1, 1}]}, {x, 0, 10}]; r = {}; s = {}; u = {}; Dynamic[ GraphicsGrid[{{ Plot[Log[r[[-1]] + s[[-1]] x^2], {x, Min@data[[All, 1]], Max@data[[All, 1]]}, PlotLabel -> "Fitting", Frame -> True, Epilog :> {Red, PointSize[Medium], ...


6

Perhaps something like this? text = ""; EventHandler[ InputField[Dynamic@text, String, ContinuousAction -> True], {"ReturnKeyDown" :> Paste["\n"]} ]


6

The problem seems to be that a TagBox that is generated is handled incorrectly by the front end. The TagBox has the form TagBox[bigExpr, Deploy, DefaultBaseStyle -> "Deploy"]. In this expression the second argument Deploy is quite meaningless. I couldn't trace any further than this TagBox as I cannot see how the front end handles it. How the kernel ...


6

In your example the resolution of image is going to zero with number of points and you will see the scattered field after addition of some dozens of thousands of points.. What is the sense of such drawing and moreover the sense of dynamic updates of such graphics? May be it is better to use something like this, with pre-defined size: data = Table[0, {i, ...


6

The reason for this behaviour is that as soon as the cursor gets away from a particular vertex marker it leaves the associated EventHandler. Here's a work-around, let's associate the event handler with the whole Graph. We just need to take care of updating the proper pos. DynamicModule[{ind = 1, pos1 = {1, 0}/2, pos2 = {1, 1}/2, pos3 = {-1, 0}/2}, ...


5

The descriprion of the problem seemed to me similar to other issues I've faced in the past. ContinuousAction->True option for InputField helped me then and OP confirms that it helps in his case too. So at the end, MWE introduced by Simon Woods should be expanded to: Column[{ InputField[Dynamic[test[[1]]], String, ContinuousAction -> ...


5

Your code seems to intend to do something a little different than what I understood from the question - so I hope this is right. :) Fixing the code require two changes, remove Deploy -- it makes the EventHandler inoperative; and put Dynamic around the argument pt -- one of the important attributes of Dynamic is that it is HoldFirst, which allows the ...


5

Quick fix to your code would be to add Row and Spacer[0]. a=0; DynamicModule[{x}, Row@{Slider[Dynamic[x]], Dynamic[If[x>.5,a=1;, Spacer[0]]]}] Instead of Spacer[0] you can use empty string: "", or Invisible[""]. Those braces are in output because you put them there. To know more about organizing an output, take a look at documentation: tutorial / ...


5

The code is bit complicated, at least the prospect of explaining exactly what's going on seems complicated. Roughly some principles that can help someone understand what's going on. In Manipulate[body, etc], anytime a variable that body depends on changes, body will be executed. Nested Dynamic and Refresh within body will make things more complicated ...


5

To save and restore data, you could use a Button for saving and an ActionMenu for restoring. The defaultParameters could just be the data -- you have to remember what order you put things, but usually that is important only in two or three places (the Button, the ActionMenu, and your case initializing defaultParameters). Merely for demonstration purposes I ...


5

Starting with a styling funtion: st = Style[#, If[PrimeQ@#, {Bold, Blue}, Gray]] &; For fast operations and small tables you can use MapAt: Animate[ MapAt[st, Range@100, List /@ Range@i] ~Partition~ 10 // Grid, {i, 0, 100, 1} ] In version 9 you can use Span for better performance: Animate[ MapAt[st, Range@100, ;; i] ~Partition~ 10 // Grid, {i, ...


5

Where exactly do you run into problems? Maybe I don't understand your question, but you can 1. just substitute the expression DynamicModule[{c = 11}, Grid[Map[Button[ToString@#, c = #, Background -> Dynamic[If[Mod[#, c] == 0, Green, White]], ImageSize -> {32, 32}, Appearance -> "Frameless"] &, ...



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