0
$\begingroup$

I have 3 variables. I want to create an interactive list of items in a Wolfram notebook that if I choose each item, functions that are written by myself change the value of the variables and recalculate all the expressions. For example items are a b c and the variables are a1 a2 a3. If I choose item a, I want item a to become equal to b, etc. Then all related calculations should automatically be updated. I was wondering if anyone can help me in creating such a functionality.

$\endgroup$
2
  • 2
    $\begingroup$ Look at the documentation for Manipulate $\endgroup$
    – Bob Hanlon
    Aug 16, 2021 at 22:38
  • 1
    $\begingroup$ Include the code of what you have tried. $\endgroup$
    – Edmund
    Aug 16, 2021 at 23:19

1 Answer 1

1
$\begingroup$

Quick solution

Create a slider for 'a' between 0.1 and 1; you can change the slider's value as shown in the animation.

{Slider[Dynamic[a], {0.1, 1}], Dynamic[a]}

slider

Now create a plot for Sin[a x]. The Plot is wrapped inside a Dynamic[ ... ] block so that it refreshes automatically when 'a' changes. Evaluate the cell.

Dynamic[
 Plot[Sin[a x], {x, 0, 2 \[Pi]}, 
  PlotTheme -> "Monochrome",
  GridLines -> Automatic,
  PlotRange -> {{0, 2 \[Pi]}, {-1.1, 1.1}}
  ]
 ]

enter image description here

Now you can create three such sliders. Remember whatever you need changed must be wrapped in a Dynamic block.

More advanced functionality is available through Manipulate for which you need to read the docs.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.