Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.4K Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Assign values to vector components using "Manipulate"

Posted 5 years ago
POSTED BY: Andrej Pustisek
6 Replies

Perfect!!!! Thank you very much.

POSTED BY: Andrej Pustisek

Thank you so far. Any solution for the second problem would be welcomed.

POSTED BY: Andrej Pustisek
Posted 5 years ago

This is merely a beginner's problem When you define a variable for Manipulate it accepts a different name (eg. $471 etc.) Whenever you try to generate such a name (using do, Table, Array etc.) (rather than write it explicitly) the generation works but not with the local name.

So

Manipulate[
 Array[n, 5], 
 Evaluate[Sequence @@ Array[{{n[#], 1}, 0, 5} &, 5]]]

will display (rightfully)

{n[1],n[2],n[3],n[4],n[5]}

to enforce the evaluation of these "generated variables" you need to use Evaluate[ ]

Manipulate[
 Evaluate[(Array[n, 5])], 
 Evaluate[Sequence @@ Array[{{n[#], 1}, 0, 5} &, 5]]]

However, this does not solve the second issue of assigning the value to the vector. I checked all the possibilities that I'm aware of. This happens since the assignment is applied immediately, therefore the right hand side of the assignment is not getting the values of n[1],,, (unless of course, u you use the names of the variables explicitly, and then you do not have a problem in the first place...) If I'll find a way , I'll publish it later

POSTED BY: Updating Name
POSTED BY: Andrej Pustisek

After a struggle I found that this seems to work:

Manipulate[mpl[Table[parameter1[k] = n[k], {k, max}],
   Sequence @@ Table[{n[k], 0, 5}, {k, max}]] /. mpl -> Manipulate,
 {max, 1, 5, 1}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard