Tag Info

New answers tagged

0

Here's my take. First, I'd use NDSolve because having the separate ParametericFunction solutions seems like the ODE has to be solved for each variable (am I wrong?). In any case, NDSolve seems simple enough since most of the parameters are Manipulate variables. Next, I'd separate the solution of the ODE from drawing the graphics by means of an extra ...


3

I would localize the variables inside the DynamicModule created by the Manipulate by using the ControlType -> None (or simply None for short) specification. This use is discussed here: What does None mean in a control specification for Manipulate? ControlType -> None Vs. Module inside Manipulate (i.e. making everything local) Code: ...


2

Manipulate[a = Plot[x, {x, 0, 1}]; b = Plot[1 - z, {z, 0, 1}]; Show[If[cond1 == 1, a, Graphics[]], If[cond2 == 1, b, Graphics[]], Axes -> (cond1+cond2>=1), PlotRange -> {{0, 1}, {0, 1}}, AspectRatio -> 1/GoldenRatio], Grid[{{Control[{{cond1, 1, ""}, {0, 1}}], "a"}, {Control[{{cond2, 1, ""}, {0, 1}}], "b"}}]] Change Axes -> ...


2

ParametricNDSolveValue is made for such problems: sol = ParametricNDSolveValue[{y1'[t] == -k1*y1[t]*y2[t] + k11*y3[t], y2'[t] == -k1*y1[t]*y2[t] + k3*y5[t] + k11*y3[t], y3'[t] == k1*y1[t]*y2[t] - k2*y3[t]*y4[t] + k22*y5[t] - k11*y3[t], y4'[t] == -k2*y4[t]*y3[t] + k22*y5[t], y5'[t] == k2*y3[t]*y4[t] - k22*y5[t] - k3*y5[t], y6'[t] == ...


0

Here is a quick example to get you started. You'll have to create a list of values for kA and kB. Just do table from 0.001 to 1.0 for both of them. kA=Table[i,{i,0.001,1.0,0.001}]; kB=Table[i,{i,0.001,1.0,0.001}]; Manipulate[ { eqA = A'[t] == -kA[[i]]*A[t]; eqB = B'[t] == kA[[i]]*A[t] - kB[[i]]*B[t]; eqC = c'[t] == kB[[i]]*B[t]; soln = NDSolve[ ...


2

Here's a quick one. It'd be wise to solve the equations for a set of variables k1,...,k22 just once. This is possible with dynamic programming revised1[k1_, k2_, k3_, k11_, k22_] := revised1[k1, k2, k3, k11, k22] = NDSolve[{y1'[t] == -k1*y1[t]*y2[t] + k11*y3[t], y2'[t] == -k1*y1[t]*y2[t] + k3*y5[t] + k11*y3[t], y3'[t] == k1*y1[t]*y2[t] - ...


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.


0

You can construct your list within the argument of manipulate using NestList (see its documentation). This function applies a function you give it (e.g. your $g$ function) to an argument repeatedly. For instance, the following expression starts from the value $2$, applies the pure function 3# & to it (= "take the argument, multiply it by 3"), and ...


6

Without a more complete example of your function all I can offer are bare guidelines to (hopefully) point you in the right direction. The first level is merely syntactical; you would use OptionsPattern, OptionValue etc., in a high level function simply for convenience, but pass all arguments as machine types to an inner compiled function. A second level is ...


2

As in my comment, I feel, it's cleaner to use Show[(Pick[HoldComplete[{regionPlot, contourPlot}], {{True, showQPlane}}])[[1]]] Additionaly I use SetDelayed in the definition of contourPlot to prevent evaluation at definition and HoldComplete makes sure that first Pick is run, and only then what's left is evaluated. [[1]] strips the result of Pick of the ...


1

This is a minimal example of how to do something like this: Manipulate[ plot1 = Graphics3D@Sphere[{0, 0, 0}, 1.3]; If[x, Print@"Calculating plot2"; plot2 = Graphics3D@Cylinder[]]; Show[{plot1, If[x, plot2, {}]}] , {{x, True}, {True, False}} ] Body of the Manipulate is inside Dynamic so if you want to be able to control what is sent to ...


2

Might you be looking for this? The modifications are in the addition of the zeros table (though it would be much better to write down an analytical expression) and the rule for Epilog acts on it accordingly to generate the points. In my example, though, they are black for a small slope and become brighter red/green for larger negative/positive slopes. You ...


5

I do this all the time, but use small buttons next to the slider. This is handy when one wants to jump to specific value, and sometimes it is hard to get the slider to go there exactly without few hits and misses and one ends up opening the slider using "+" and typing in the value in the small window which is not very efficient sometimes. Here is an example ...


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


2

There are two issues going on here, though only one of them is preventing your plot from working in the Manipulate. The first is, as noted by xzczd in comments, that you need to get Mathematica to see that the \[Beta] in the expression for x[t]/. s is the same one you are using as the variable to be manipulated. You can see this is an issue with a slight ...


1

Below is the answer: Manipulate[Plot[ Evaluate[x[t] /. NDSolve[{x''[t] + 2 \[Beta] x'[t] + 4 x[t]== 0, x'[0] == 0, x[0] == 1}, x, {t, 0, 4}]], {t, 0, 5}], {\[Beta], 0,4,0.1}] thank you for asking


1

There are two issues here. The first one can be explained easily because you simply forgot that your button needs to do something. Just evaluating your Manipulate is not going to do what you like, because you need to see it on screen when you want to interact with it. Therefore, you need to Print or CellPrint your Manipulate. The second issue arises when ...


6

One difficulty in using Manipulate is that it rewrites your code for you in ways that are not clearly explained in the documentation. The thinking is that this rewriting achieves the dynamic interactions described in the documentation without burdening the programmer with some of the tedious details involved. For instance, expressions that contain ...


4

You need to do some initialization. Manipulate often behaves strangely when its controls are not initialized properly. f[u_] := If[u <= 1, 5, 0]; Manipulate[ Column[{ Row[{"x: ", x, " f[x]: ", f[x]}], Row[{"ang: ", ang, " f[ang]: ", f[ang]}]}], {x, 0, 2}, {{ang, x}, x, 2}] (* initialization added to control *)


2

This is not an answer but rather an extended comment to @kguler to demonstrate Appearance -> "Labeled" with Slider2D in version 10.1 $Version "10.1.0 for Mac OS X x86 (64-bit) (March 24, 2015)" Using @kguler answer Manipulate[ Graphics[{Polygon[{pt1, pt2, pt3}]}, PlotRangeClipping -> False, Frame -> True, PlotRange -> {{0, 10}, ...


4

You can attach multiple controls to a variable: Manipulate[Graphics[{Polygon[{pt1, pt2, pt3}]}, PlotRangeClipping -> False, Frame -> True, PlotRange -> {{0, 10}, {0, 10}}], {{pt1, {0, 0}}}, {{pt2, {0, 1}}}, {{pt3, {1, 1}}}, Row[{Control@{{pt1, {0, 0}}, {0, 0}, {10, 10}, Slider2D}, Control@{{pt2, {0, 1}}, {0, 0}, {10, 10}, Slider2D}, ...


1

I hate fiddly held expressions! But I managed to get this Dynamic construct to work. n = 4; left[x_, y_, z__] := Abs@Product[x + I y - Complex @@ zz, {zz, {z}}] right[z__] := Abs@Product[Complex @@ zz, {zz, {z}}] DynamicModule[{z = RandomReal[{-5, 5}, {n, 2}]}, Dynamic[Show[ ContourPlot[ left[x, y, Sequence @@ z] == right[Sequence @@ z], {x, ...


0

To make more automatic approach we can use some knowledge shared by MichaelE2: Manipulate: How to create custom reset Button automatically? EKSWaveFormControl[] := Manipulate[ Plot[ctrlVdc + ctrlVac ctrlgFunc[2 \[Pi] ctrlf t + ctrlPhi], {t, 0, 0.4}], {{ctrlgFunc, Sin, ""}, {Sin, Cos, Tan, Cot}}, Delimiter, {{ctrlVac, 1.5, Subscript["V", ...


3

Here's an approach using ParametricPlot, where ListAnimate permits smooth animation. testparaNew[α_] := Show[{ ParametricPlot[ {{Cos[θ], Sin[θ]}, {2 Cos[α] + Cos[θ], 2 Sin[α] + Sin[θ]}}, {θ, 0, 2 π}, PlotRange -> 3, Axes -> False, Frame -> False ], ParametricPlot[ {{2 Cos[α] + r Cos[2 α + π], 2 ...


4

Here is the simple method I use. I create a button (with label "[[?]]") that finds the position of the current selection in the last output. You can add the button to a custom utilities palette for easy access. Button["\[LeftDoubleBracket]?\[RightDoubleBracket]", Print@Position[%, ToExpression@CurrentValue@"SelectionData"]] Here's how to use it to grab ...


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


2

myS[x_, y_, a_] := Sin[x y + a]; Manipulate[ Plot3D[myS[x, y, a], {x, -2, 2}, {y, -2, 2}], {a, 0, 5}] Incidentally, as a general rule, avoid using variable or function names that begin with an upper-case letter as these may conflict with internal names used by Mathematica.


0

There are a few issues with your code. You have not defined your functions correctly. Look up Defining Functions in the documentation. You would be repeatedly executing the Solve in Manipulate once you got the plot to work. This can be put in the Initialization since it does not change as you adjust your variables. You can put the constants A and n in the ...


3

Is this something like what you want? Manipulate[Show[ Graphics[{ Circle[{0, 0}, 1], Circle[{2 Cos[t], 2 Sin[t]}, 1], {Blue, PointSize[0.012], Point[{Cos[t], Sin[t]}]}, {Green, PointSize[0.012], Point[{2 Cos[t], 2 Sin[t]}]}, Line[{{2 Cos[t], 2 Sin[t]}, {2 Cos[t], 2 Sin[t]} + {Cos[Pi + 2 t], Sin[Pi + 2 t]}}] }, ...



Top 50 recent answers are included