Message Boards Message Boards

0
|
2512 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

In Manipulate function, can the second argument be written as a Table?

Posted 10 years ago

Hi, good morning everybody. The number of variables to manipulate is a variable itself, I need to generate the second argument of Manipulate with a Table. How can it be done? Something like:

 Manipulate[X,Table[{X[[i]],Xmin[[i]],Xmax[[i]]},{i,1,n}]]

where X is a vector with n variables and Xmin and Xmax are vectors with minimum and maximum ranges.

POSTED BY: Fabio S.
3 Replies

Sequence very often has to be used with Apply. Both of these functions are pretty strange and probably best avoided.

If you program the Wolfram Language like it's a functional programming language, you will never use these two functions and your code becomes much easier to read and test.

POSTED BY: Sean Clarke
Posted 10 years ago

Thank you Sean, it is exactly the answer I was looking for. Actually I didn't know about the apply '@@' function, I was unsuccessful because I used Sequence followed by [ ]. Where the apply function is coming to be helpful, beside this case? The power of this language is really impressive.

POSTED BY: Fabio S.

A variable number of manipulates... I guess the answer depends on how you have structured your code. Do you want the number of manipulates to depends dynamically on some kind of value?

n = 6

Manipulate[Evaluate@Table[u[i], {i, 1, n}], 
 Evaluate[Sequence @@ Table[{u[i], 0, 1}, {i, 1, n}]]]

Evaluate is needed to ensure that the arguments will evaluate. Manipulate holds its arguments. Sequence is needed to turn the list from Table into a sequence of statements.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract