Tag Info

Hot answers tagged

8

use ImagePadding as in f[x_, a_, b_] := a x - b x^3 Manipulate[ { Plot[f[x, a, b], {x, -2, 2}, ImagePadding -> 5], n = -Integrate[f[x, a, b] , x]; Plot[n, {x, -2, 2}, PlotRange -> Automatic, ImagePadding -> 5] }, {{a, 1/2, "control parameter"}, -1, 2, 0.1}, {{b, 1/4, "control parameter 2"}, -1, 2, 0.01} ]


7

There are a lot of different ways to do this. My current favorite is Manipulate[{a, b}, {a, 1, 10}, {b, 1, 10, TrackingFunction -> (b = #; a = 10; &)}]


6

The option for a Manipulate control, that mimics the functionality of the second argument to Dynamic is TrackingFunction. f[x_] := Sin[x] Manipulate[ Column[{Show[Plot[f[x], {x, 0, 2 Pi}, Axes -> False, Frame -> True]], p}], {{p, {0, 0}}, Locator, TrackingFunction -> (p = {First@#, f@First@#}; &)}] Using only Manipulate and no ...


6

You can do this: Modify the If statement in the second argument of dynamics as you like. I set it now to jump by 0.2 if c<0 and jump by 0.01 if c>0 but you can change this. f[x_] = Piecewise[{{-x, x < 0}, {x^2, x >= 0}}]; g[x_] = Piecewise[{{-1, x < 0}, {2 x, x > 0}}]; Manipulate[ Plot[{f[x], f[c] + g[c] (x - c)}, {x, -3, 3}, Epilog ...


5

With the arbitrary datasets datasets = {dataset1, dataset2, dataset3} = RandomReal[#, 100] & /@ {1, 2, 3}; one can pre-render the plots and add an empty plot for the case when no dataset is selected plots = Append[ MapThread[ListPlot[#1, Joined -> True, PlotStyle -> #2] &, {datasets, ColorData[97] /@ Range[3]}], ...


4

EDIT: Pulled definition of f outside of Manipulate to avoid update issue pointed out by @MichaelE2 To keep the Flow from dominating the scale of the Plot and making it difficult to see the other two curves, I multiplied the Flow by Ro f[t_, Caorta_, Rsystemic_, x_, \[Omega]_, k_, Ro_] := Paorta[t] /. NDSolve[ {Paorta'[t] == 1/Caorta ((1/2*k*(1 + ...


4

Perhaps cleaner w[k_, ω_, t_] := 1/2*k*(1 + Cos[ω t]) + 10; pnd = ParametricNDSolve[{ Paorta'[t] == 1/Caorta ((w[k,ω,t] - Paorta@t)/ Piecewise[{{ρ, w[k,ω,t] - Paorta@t >0}}, x*ρ]- Paorta@t/Rsystemic), Paorta[0] == 90}, {Paorta}, {t, 0, 10}, {Caorta, k, ω, ρ, x, Rsystemic}] Manipulate[ Plot[ {#, w[k,ω,t], (w[k,ω,t] - ...


4

You've got Evaluate in the wrong place. It has to be of the form Plot[Evaluate[stuff to plot...],...] So this seems to work: Manipulate[ Plot[Evaluate@{ (ReplaceAll[Paorta[t], NDSolve[{Paorta'[t] == 1/Caorta ((1/2*k*(1 + Cos[ω t]) + 10 - Paorta[t])/ Piecewise[{{Ro, 1/2*k*(1 + Cos[ω t]) + 10 - Paorta[t] ...


4

Here's the basic idea, where you can adjust the function, limits, and Piecewise arguments for your specific case. Manipulate[ Plot[{120 - 50 x^2, 120 - 50 Sqrt[x]}, {x, 0, 1}, PlotRange -> {70, 120}, Filling -> {1 -> {2}}, PlotStyle -> {Green, Blue}, FillingStyle -> LightGray, Epilog -> {Red, PointSize[0.03], Point[{.5, ...


4

You must use a Dynamic[] in your Manipulate[]. It is documented in the "Advanced Manipulate Tutorial" (chapter "Using Dynamic inside Manipulate") : solveDiffEq[a_] := { sol = NDSolve[ {f''[t] == a*f[t], f[0] == 1, f'[0] == 1}, f, {t, 0, 1}]; {AbsoluteTime[], f[t] /. sol[[1]]} }; Manipulate[ s = solveDiffEq[a0]; Dynamic[s /. t ...


3

Managing Manipulate and other Dynamic functionality is tricky. It takes some time reading the tutorials and experimenting to sort it all out. Even then you might still get surprised now and then. The trick is to separate the code segments that need updating using Dynamic, Refresh, and sometimes DynamicWrapper; further, one needs to control which symbols ...


3

Apart from szabolcs' dirty trick, a generic way to resolve this would be to precalculate one plot g=ContourPlot[f==0,{x,-5,5},{y,-5,5}]; And then use manipulate with the precalculated plot Manipulate[Show[g,Plot[m*x,{x,-5,5}]],{m,-5,5}]


3

That won't work because Epilog yields 2D graphics primitives, so you can't have plot a moving 3D point using Epilog. Instead, make a separate Graphics3D object and Show both of them. So, for instance defining parPlot = ParametricPlot3D[ {x[t], y[t], f[x[t], y[t]]} , {t, 0, 6 Pi} , PlotRange -> All , PerformanceGoal -> "Quality" ]; we can ...


3

You can use IntervalSlider in version 10.0 and above. However, you need to explicitly tell Manipulate to use it. Manipulate[ fShowInterval[Sequence @@ probRange], {probRange, 2000, 4000, IntervalSlider, Method -> "Push", MinIntervalSize -> 1}, Initialization :> (probRange = {2500, 3500};)] Method -> "Push"will keep the interval ...


3

I was pinging Vitaliy Kaurov about this issue some time ago. Lucky for us, our site seems to have quite some members from the WRI development team. Some time later I got a response from Ilian Gachevski saying @halirutan fixed in the development version (chatlog) This means we just have to wait for the next release.


3

Manipulate typically changes the default value of the $PerformanceGoal control to "Speed" instead of "Quality", in order to speed up evaluation of dynamic content (see the first "basic example" in its documentation page). Typically this doesn't matter much, but in some cases this can influence the outcome of some algorithms that are sensitive to the working ...


3

The following much simpler Manipulate shows one way, how to get a label in Degree, while the variable value is in radian. Manipulate[x, Row[{Control[{{x, 0 Degree}, 0 Degree, 100 Degree}], Spacer[10], Dynamic[x/Degree], "\[Degree]"}]]


3

One can add the option Appearance -> "Labeled" to a Slider2D to have the current values shown as an editable label. Manipulate[ Graphics[{PointSize[Large], Point[p]}, PlotRange -> 1], {{p, {1, 1}}, {-1, -1}, {1, 1}, Appearance -> "Labeled"}] Using two 1D Slider Manipulate[ Graphics[{PointSize[Large], Point[{px, py}]}, PlotRange ...


3

Some of this code is based on the last example of the docs on GradientOrientationFilter You can also smooth out the resulting path and reparametrize the interpolation based on the curve length to get a "constant velocity" displacement for the rectangle- l1 = Line[{{0, 1}, {1, 1}}]; cir = Circle[{1, 0}, 1, {-π/2, π/2}]; l2 = Line[{{0, -1}, {1, -1}}]; geom = ...


2

It seems your Sector returns a region for which RegionMember can calculate its formula. RegionPlot is quite a bit faster on this fairly simple formula than on the region. Further, you don't run into the symbolic-numeric problem of reducing the RegionIntersection in whatever way Mathematica does under the hood. (I suspect it is using a algebraic/symbolic ...


2

I'm pretty sure there ought to be something cleaner. While we wait for a better answer, you may use this to return the minimum and maximum number of arguments allowed for each wavelet: nArgs[fun_] := StringCases[ToString@DownValues@fun, Shortest["ArgumentCountQ"~~__~~(n1:NumberString)~~__~~ (n2:NumberString)] :> ...


2

use ImageSize on the slider. For example Manipulate[{a, b, c}, {{a, 1, "a"}, .1, 1, .1, ImageSize -> Large}, {{b, 1, "b"}, .1, 1, .1, ImageSize -> Tiny}, {{c, 1, "c"}, .1, 1, .1, ImageSize -> Small} ]


2

Manipulate[Grid[{{ Plot[Sin[x + a], {x, -3, 3}], Plot[BesselJ[x + a, 2], {x, -3, 3}] },{ Plot[Cos[x + a], {x, -3, 3}], Plot[BesselJ[x + a, 4], {x, -3, 3}] }}], {a, -3, 1}]


2

Probably cleaner: f[x_, y_] := 2 E^(-x^2 - y^2); pos[t_] := {##, f@##} & @@ (t/8 {Cos[t], Sin[t]}) Manipulate[ Show[ Plot3D[f[x, y], {x, -Pi, Pi}, {y, -Pi, Pi}, PlotRange -> All, Mesh -> None, PlotStyle -> Opacity@.5, Boxed -> False], ParametricPlot3D[pos@t, {t, 0, 6 Pi}], Graphics3D@{Red, PointSize -> .05, ...


2

Both styles are possible Row[{ Manipulate[ ContourPlot[ a[x, y] == 0, {x, -5, 5}, {y, -5, 5}], {{a, #1 - #2 &}}], Manipulate[ ContourPlot[ a == 0, {x, -5, 5}, {y, -5, 5}], {{a, x - y}}]} ] Edit Answering your comment below, you may use the function in many ways. Here I numerically solve a differential equation involving it: ...


2

It is always a pain to adjust everything in complex Manipulate but if you insist :) Manipulate[ {filter, list} , {{filter, 1, "Filter:"}, {1, 2, 3, 4, 5, 6}, ControlType -> PopupMenu} , {list, None} , Grid[{{"List:", PopupMenu[ Dynamic[list, If[# < filter, , list = #] &], # -> Dynamic[Style[#, If[# < filter, Gray, ...


2

One can make c and a stepsize with an If statement interdependent controls of the Manipulate without showing stepsize. However, this only works after making the If statement Dynamic. f[x_] = Piecewise[{{-x, x < 0}, {x^2, x >= 0}}]; g[x_] = Piecewise[{{-1, x < 0}, {2 x, x > 0}}]; Manipulate[ Plot[{f[x], f[c] + g[c] (x - c)}, {x, -3, 3}, Epilog ...


2

One can localize the scope of variables to Manipulate by adding them as arguments to Manipulate with ControlType None. For your case Manipulate[Refresh[lower = distPlotRange[distribution, -1, 4]; upper = distPlotRange[distribution, 1, 4]; fillRange = {Max[#[[1]]], Min[#[[2]]]} &[ Transpose[{fillRange, {lower, upper}}]];, TrackedSymbols :> ...


1

I received an answer from support that it's a Manipulate bug. The following code is stable(it's working on Mathematica 10, Windows 7): co = 2.0*^8; ω = 2 Pi \[ScriptF] 10^6; τ = \[ScriptCapitalT] 10^-9; t = ts*10^-9; sol = Solve[{a + b == 1, (a E^(-I ω τ) + b E^(I ω τ)) == (a E^(-I ω τ) - b E^(I ω τ))*RL/Z0}, {a, b}]; Vi[ts_, x_, ...


1

It's a DynamicModule not a Manipulate, but it works (Mma V10.1 on Mac and Windows) DynamicModule[{filter, list = 1}, Column[{ PopupMenu[Dynamic[filter], Range[6]], PopupMenu[Dynamic[list], Table[With[{i = i}, (If[i < filter, list = list, list = i]) -> i], {i, 6}]], {"filter", Dynamic[filter]}, {"list", Dynamic[list]} }]] ...



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