Tag Info

Hot answers tagged

7

Here is a rework of your code that I think produces what you are asking for. One issue I have not addressed is plot filling because I think it a bad idea with so many functions on the plot. I also made some minor changes to the control layout to get a more compact display. You can easily restore your original layout if you like. Manipulate[ Column[ ...


5

Clear[xp] xp[t_, r_, t0_, x0_] := x[t] /. First[NDSolve[{x'[t] + r x[t] == 0, x[t0] == x0}, x[t], {t, 0, 10}]]; Manipulate[ ClickPane[ Plot[g, {t, 0, 10}, PlotRange -> 1, Frame -> True, PlotLabel -> Dynamic[MousePosition["Graphics"]], Epilog -> {PointSize[Large], Point[sp]}], ...


4

Re NDSolve::ndsz: Using WhenEvent, one can stop the integration before the solution reaches an infinite singularity, which is what is happening with the example differential equation. I removed the Quiet so one might test it. If the differential equation is changed, then it would be possible to get the message to appear. Use Quiet to suppress it, Check to ...


3

There are couple of ways to handle your problem. Simple -- give a warning of slider interference: Manipulate[ If[t1 < t2, Plot[t^2, {t, t1, t2}], "Warning: t1 > t2"], {{t1, -1}, -2, 2, 0.1, Appearance -> "Labeled"}, {{t2, 1}, -2, 2, 0.1, Appearance -> "Labeled"}] More elegant user interface, less elegant code -- prevent slider ...


3

I think your Quiet is not in the right place, and you may need another one. For f: f[t_, a_, b_, t0_, x0_] := Quiet[u[t] /. First[NDSolve[{u'[t] == ODE, u[t0] == x0}, u, {t, -2, 2}, Method -> "StiffnessSwitching"]]]; gets rid of the NDSolve warning. Then add another Quiet around the Plot: Quiet[Plot[g, {t, -2, 2}, PlotRange -> 2, ...


2

The following turns off the warning messages, but is not really a good solution, since it doesn't deal with the root problem of the trouble NDSolve is having with your differential equation. sf[eq_, A_, B_] := VectorPlot[{1, eq /. {a -> A, b -> B}}, {t, -2, 2}, {x, -2, 2}, VectorPoints -> 17, VectorScale -> {0.03, Automatic, None}, ...


2

Manipulate[{ m = {{a, b}, {c, d}}; Column[{r = Thread[m.{x, y} == {f, g}], s = LinearSolve[m, {f, g}]}], ContourPlot[Evaluate@r, {x, -5, 5}, {y, -5, 5}, PlotLabel -> s]}, {{b, 3}, 0, 3}]


2

Expanding on Kuba's answers, if you use Dynamic for both controls I believe you can fully accomplish your goal. When you set filter it will both gray out the elements less than the filter in list and if the element in list is less than the filter it will reset it to the filter value. Manipulate[ {filter, list}, (* Manipulate Controls *) {{filter, 1}, ...


2

Perhaps: f[aa_, oo_, pp_] := CreateDialog[ Column[{Manipulate[ Plot[(aa = amp) Sin[(oo = omega) t - (pp = phi)], {t, 0, 10}], {amp, 0, 1}, {omega, 1, 10}, {phi, 0, 2 Pi}], DefaultButton["Close", DialogReturn[]]}], Modal -> True]; Dynamic[{a, o, p}] f[Unevaluated@a, Unevaluated@o, Unevaluated@p]


2

Another approach slightly different from LLIAMnYP's answer to is to go ahead and treat the x and y variables as local to Manipulate. In this approach x and y are updated dynamically and used to compute the intermediate results, q and w. x and y are used to directly compute f but the intermediate results are used to compute z. One uses DyanmicModule to ...


2

The problem here is scoping. x and y inside the Manipulate are not the same x and y that you use globally. In order to remedy this, use the option LocalizeVariables -> False. Manipulate[{q = 2 x, w = 3 y}, {x, 0, 10}, {y, 0, 10}, LocalizeVariables -> False] (* slide around *) x (* 3.74 *) z = 4 q + 5 w f = 3 x + 4 y (* 103.72 *) (* 30.9 *) Perhaps a ...


2

data = FinancialData["IBM", "Jan. 1, 2014"]; Manipulate[ Block[ {x = DatePlus[data[[1, 1]], t]}, DateListPlot[ data , Epilog -> Line[ { {x, Min@data[[All, 2]]} , {x, Max@data[[All, 2]]} }] ] ], {t, 0, QuantityMagnitude@ DateDifference[First@First@data, First@Last@data]}]


2

Since this has gone unanswered for so long and I can add one clarification to the comments under the question, I'll fill out an answer. In the comments, it has been observed that the following work (with the appropriate definition of customControl): {{x, 0}, customControl[#1, y] &} {{x, 0}, customControl[Dynamic[x]] &} {{x, 0}, ...


1

Just following up Mr.Wizard's comment (remove Module), you can localize the other variables with With or however one wishes, or let them be global. Manipulate[ With[{ o1 = {0, 0}, o2 = {g, 0}, crankPosition = c*{Cos[θ], Sin[θ]}}, With[{ groundLink = Line[{o1, o2}], crank = Line[{o1, crankPosition}]}, Show[Graphics[{groundLink, ...


1

This is now my final Code (V10.02). Thanks a lot for the help m_goldberg ! Manipulate[ Plot[Evaluate[checkBoxes/.{ 1-> 1,2-> Log[n],3-> n,4-> Log[n]n,5-> n^2}],{n,0,d}, PlotLabel->TableForm[{{"Funktion","Value"}, Sequence@@DeleteCases[MapThread[If[#1,#2,Null]&, {MatchQ[Alternatives@@checkBoxes]/@Range[5], ...


1

I've not answered any questions with this example, but I added tmin, tmax, xmin, xmax, and adjusted when to halt the integration. I don't know yet how to handle the Check command in MichaelE2's comment, so that still remains in the code. Manipulate[ClickPane[Show[Plot[g, {t, tmin, tmax}, PlotRange -> {{tmin, tmax}, {xmin, xmax}}, Frame -> ...


1

Here's how I would do it: Manipulate[ Plot[f[x], {x, a, b}, PlotStyle -> Thick, AxesLabel -> {"x", "y"}, Epilog -> Dynamic@{Table[{Opacity[0.05], EdgeForm[Gray], Rectangle[{a + i dx[n], 0}, {a + (i + 1) dx[n], f[a + (i + 1) dx[n]]}]}, {i, 0, n - 1, 1}], Text["N = " <> ToString[n] <> ", R = " <> ...


1

The use of ExportString and/or ImportString, which in fact just use Export and Import on temporary files, seems to trigger dynamic updates. Front-End options get changed and perhaps some variables, and it must be that some of these are tracked. It's difficult to know whether they ought to be or not. In any case, a side effect is the continual updating of ...



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