1

I am trying to change a variable using Manipulate, like this:

var = something;
var = 
  Manipulate[f[var, {a, b, c}],
    {{a, .8}, -1, 1},
    {{b, 0}, -1, 1},
    {{c, 0}, -1, 1}];

var

I read the Manipulate and the Dynamic tutorial in the Wolfram documentation, but I still can't figure it out.

Does anyone got any clue? Other than, this ?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257

2 Answers2

3

You could do something like this.

var = 42;

SetAttributes[f, HoldFirst]
f[v_Symbol, {a_, b_, c_}] := (v = (a + b)/(2 + c))

Manipulate[f[var, {a, b, c}],
  {{a, .8}, -1, 1, Appearance -> "Labeled"},
  {{b, 0}, -1, 1, Appearance -> "Labeled"},
  {{c, 0}, -1, 1, Appearance -> "Labeled"}]

enter image description here

Dynamic @ var
0.49

The dynamic evaluation of var is made to show that the global value var is updated as the sliders move.

Kuba
  • 136,707
  • 13
  • 279
  • 740
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
1

Try this:

Manipulate[
 Plot[a*x^2 + b*Sqrt[x] - x, {x, 0, 10}],
 {a, 1, 4}, {b, 0, 10}
 ]

Where you may call var=a*x^2 + b*Sqrt[x] - x in your post. You should be able to get the plot of this function var.

your post has other problems such as var is something and something is assigned to Manipulate. Many thing are mixed up in your question.

Tugrul Temel
  • 6,193
  • 3
  • 12
  • 32