Skip to main content
added 41 characters in body
Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

You're randomizingYou need to randomize the wrong control parameterinitial value, not the name of the symbol associated to the control. 
Perhaps this is what you want something like this instead:

Manipulate[
 With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], s[i]}, -1, 1}, {i, n}]},
  Manipulate[f,
   controls,
   Button["Random", Do[s[i] = RandomReal[{-1, 1}], {i, n}]]]],
 {n, {3, 4, 5}}, Initialization -> {s@_ := 0}]

Mathematica graphics

You're randomizing the wrong control parameter. Perhaps you want something like this instead:

Manipulate[
 With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], s[i]}, -1, 1}, {i, n}]},
  Manipulate[f,
   controls,
   Button["Random", Do[s[i] = RandomReal[{-1, 1}], {i, n}]]]],
 {n, {3, 4, 5}}, Initialization -> {s@_ := 0}]

Mathematica graphics

You need to randomize the control initial value, not the name of the symbol associated to the control. 
Perhaps this is what you want:

Manipulate[
 With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], s[i]}, -1, 1}, {i, n}]},
  Manipulate[f,
   controls,
   Button["Random", Do[s[i] = RandomReal[{-1, 1}], {i, n}]]]],
 {n, {3, 4, 5}}, Initialization -> {s@_ := 0}]

Mathematica graphics

Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

You're randomizing the wrong control parameter. Perhaps you want something like this instead:

Manipulate[
 With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], s[i]}, -1, 1}, {i, n}]},
  Manipulate[f,
   controls,
   Button["Random", Do[s[i] = RandomReal[{-1, 1}], {i, n}]]]],
 {n, {3, 4, 5}}, Initialization -> {s@_ := 0}]

Mathematica graphics