Tag Info

Hot answers tagged

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


6

The two examples you mention are easily understood from the way Dynamic updating works. Let us concentrate on Dynamic[x]. It is sent by the frontend to the kernel and the kernel returns it unevaluated to the frontend, together with the boxes in which the frontend will display. Then the front starts an update procedure over the preemptive link, asking the ...


3

This happens because legend items are wrapped in HoldForm to prevent the elements from taking on values: Observe: c = 5; RegionPlot[{x^2 + y^2 <= c, x < 0}, {x, -Pi, Pi}, {y, -Pi, Pi}, PlotLegends -> "Expressions"][[2, 1, 2]] // InputForm {HoldForm[x^2 + y^2 <= c], HoldForm[x < 0]} Without the HoldForm any global values (such as c ...


3

Let's try to explain this: The Dynamic never goes away and just because you don't see it on screen, doesn't mean that it isn't still there. So let's assume you have a similar function which doesn't act in such a special way as Dynamic does and let's call it freakyFunc. This function has no definition and when you use it, it is not further evaluated. The ...


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_] := ...


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


2

I wass going to post an answer about scoping issues but it seems that this problem can be narrowed down. As MarcoB has noticed, there appears to be a bug in Manipulator. var = 75; Manipulator[Dynamic[var], {50, 100, 0.2}] when you open it, var is reset to 50... If you start with "Open" it is ok. However, if you put `Manipulator to dialog, each option ...


2

I don't know what the popup menu is for -- but I've left that bit of code in there -- but this should be what you need: DynamicModule[{files, pop, images = ""}, Column[{ Row[{"Select which kind of profile you want", PopupMenu[Dynamic@pop, {1, 2}]}, Spacer[3]], Button["Image import, choose your image here", files = ...


2

A control such as slider is updating a variable and the front-end needs to know that the variable is dynamic, so the Dynamic wrapper goes on the variable. But Quantity is a display form and the front-end only needs to know that it should treat the whole form as dynamic. On my system, V10.1 running on OS X Yosemite, Quantity[Dynamic[b], lengthUnit] does ...


2

Here are some relevant stack exchange posts: Showing "updating..." message while Manipulate is re-evaluating Show Progressbar after pressing a button Evaluation indicator for a notebook Igor


2

Not sure about how to use Refresh in this case, but without it enclosing Show and point in Dynamic works: DynamicModule[{a = 0.5, point = {1, 1}}, Column@{ Slider@Dynamic@a, LocatorPane[ Dynamic@point, Dynamic@Show[ ContourPlot[Sin[a x y], {x, -5, 5}, {y, -5, 5}, ImageSize -> 300, PlotRangePadding -> None], ...


2

You can wrap the part that you want to be updated using Dynamic. Check the difference between these two codes: Manipulate[ Graphics[{{Gray, Line /@ Partition[RandomReal[{-4, 4}, {1000, 2}], 2]}, {Red, Circle[{a, b}, c]}}], {a, 0, 1}, {b, 0, 1}, {c, 1, 4}] Manipulate[ Graphics[{{Gray, Line /@ Partition[RandomReal[{-4, 4}, {1000, 2}], 2]}, ...


2

For the code to work without error messages, signa needs an initial value, for instance: Manipulate[Plot[PDF[NormalDistribution[mu, sigma], x], {x, -4*sigma, 4*sigma}], {mu, -10, 10}, {{sigma, .5}, 0, 10}] Alternatively, just tolerate the initial error messages, and move the sigma slider to obtain the desired results.


1

d[e_] = e/2; Manipulate[Row[{"d = ", d[e], Plot[2 x - 1, {x, -1, 4}, ImageSize -> 300]}, Spacer[5]], {e, 0, 5}] Perhaps a better alternative is to use Labeled and to wrap the label with Pane to avoid jittering of the plot as the size of the label changes: Manipulate[Labeled[Plot[2 x - 1, {x, -1, 4}], Pane[Row@{"d = ", d[e]}, ImageSize -> ...


1

I don't know how to do what you ask, but here is an alternative approach that you might use. snapshots = {}; Manipulate[ Plot[ctrlVdc + ctrlVac ctrlgFunc[2 π ctrlf t + ctrlPhi], {t, 0, 0.4}], {{ctrlgFunc, Sin, ""}, {Sin, Cos, Tan, Cot}}, Delimiter, {{ctrlVac, 1.5, Subscript["V", "ac"]}, -10, 10}, {{ctrlVdc, 0.5, Subscript["V", "dc"]}, -1, 1}, ...



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