Message Boards Message Boards

0
|
5533 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Dynamical matrix growth

Posted 10 years ago

I am trying to create a list that grows as new elements are entered one by one in the InputField. Tried this code:

InputField[Dynamic[ss]]
T = {};

Dynamic[AppendTo[T, ss], ContinuousAction -> False]

But ended up in infinite loop. Any ideas?

Thanks.

POSTED BY: Al Guy
4 Replies
Posted 10 years ago

Thanks.

POSTED BY: Al Guy

InputField[Dynamic[rr, {(dd = #) & }]]

You can't do the above. The symbol to the left of = has to the dynamic symbol in the first argument to dynamics which is rr.

When using the second argument of dynamics, you are overriding the default behavior of Dynamics, which is to assign to rr (the thing in the first argument) the current slider value as it is being changed. Therefore, you have now to do this yourself, by writing rr=#&, else rr will never get updated. You are now in control of Dynamics. Since you did not update rr in the second argument, it never got assigned to the input.

The second argument of dynamics can be single pure function (as in this example), or it can be a list of two pure functions. In this case, the first function is used during interaction, and the second is evaluated at end of interaction.

Or it can be a list of 3 pure functions, in this case, the first function is evaluated at start of interaction, and the second is evaluated during interaction, and the third is evaluated at end of the interaction (when you release the mouse). This way, you can have complete control of Dynamics at each phase.

POSTED BY: Nasser M. Abbasi
Posted 10 years ago

Thanks, Nasser.

Why doesn't rr being updated here? It just returns rr:

dd = Null; 
InputField[Dynamic[rr, {(dd = #) & }]]

Dynamic[dd]
Dynamic[rr]
POSTED BY: Al Guy

how about

T = {};
ss = Null;
Grid[{{InputField[Dynamic[ss, {ss = #; AppendTo[T, ss] } &]]}, {Dynamic[T]}}, Frame -> All]

enter image description here

POSTED BY: Nasser M. Abbasi
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