Tag Info

New answers tagged

0

Update: Solved my problem with the help of Kuba's advice; making multiple Dynamics. Code listed below, for anyone who is interested. Note: "SynchronousUpdating -> False" allows the animator to animate while search is 'busy'. Row[{ Column[{ InputField[Dynamic[input], String, ContinuousAction -> True], Dynamic[ Refresh[ If[ ...


2

I really don't have any experience with Interpretation, but it seems that requesting a function name or pure function rather than a function form, and initializing f to Null gives the behavior you ask for. Interpretation[{f = Null, min = 0, max = 2 Pi}, Panel[ Grid[{ {Style["Plot", Bold], SpanFromLeft}, {"Function:", ...


2

Pure function f specified as requested: "The algorithm of distribution is that if the first [or any] element changes, the other four would change proportionally." v = {0.2, 0.2, 0.2, 0.2, 0.2}; f = Function[{z, k}, {a, b, c, d, e} = v; m = n = o = p = q = 1; Switch[k, 1, a = z; m = 0, 2, b = z; n = 0, 3, c = z; o = 0, 4, d = ...


2

I think it is easier to implement the behavior the OP wants to give the list of probabilities, {p1, ..., p5} by having a setter bar to select the element to be changed and a single animator (slider) to change the value of that element. First a helper function for normalizing the probabilities after the slider is moved. adjust[probs_, pk_, k_] := ...


7

Response to edits: I don't know if I got all your points but this is the final update done by me :) v = {0.5, 0.05, 0.1, 0.15, 0.2}; active = Range@Length@v; update[i_, val_] := (v[[i]] = val; With[{range = DeleteCases[active, i]}, v[[range]] = (1 - val) Normalize[v[[range]], Total]]); updateCheckbox[i_, val_] := If[val, active = Join[active, ...


2

v = {0.5, 0.05, 0.1, 0.15, 0.2}; First we create a pure function to be used by the ith slider that (apart from the ith element) adjusts each element of the list v by the factor r - the proportionality adjustment envisioned: f[i_, r_] := Function[{val, j}, With[{n = First@j}, If[n =!= i, v[[n]] = val*r]]] In Dynamic's second argument of the ith slider, ...



Top 50 recent answers are included