For my application, I am using Dynamic functionality to make a number of input fields through which a user can enter numbers. I then take these numbers and place them as the entries in a dynamic matrix. I then use the matrix as an input to a function I've written.
For some reason, I find that Mathematica cannot do anything with a matrix that is formed in this way. Though the matrix seems to be correctly formed, I find that Mathematica will not fully evaluate any expressions involving the dynamic matrix.
Here is some example code
DynamicModule[{numElements = 3, list1,list2},Dynamic@Column[
list1=Table[Symbol["n"<>ToString@i],{i,1,numElements}];
list2=Table[Symbol["t"<>ToString@i],{i,1,numElements}];
{
InputField[Dynamic@numElements],
Dynamic@Column[Flatten@Table[{Row[{With[{i=i},InputField[Dynamic[list1[[i]]],Number]], With[{i=i}, InputField[Dynamic[list2[[i]]], Number]]}]}, {i,1,numElements}]],
stack = Table[With[{i=i}, {Dynamic[list1[[i]]],Dynamic[list2[[i]]]}], {i,1,numElements}], Button["Press to find max", Print@Max[stack]]}
]]
This generates a simple user interface that allows you to control two lists list1 and list2 with entries n1, n2, n3, etc. and t1, t2, t3, etc., and it allows you to control their length. It then takes these values and makes a 2 x numElements matrix.
However, it doesn't seem like I can do anything with this matrix. Above I tried to print out its maximum value through a button. What could be the issue here?
Dynamic
positioned in the wrong place but we need to see your code. $\endgroup$Max[Dynamic[val1],Dynamic[val2]]
, it has to beDynamic@Max[val1,val2]
. The issue is similar to lite item six here. Once you wrap your number withDynamic
it doesn't go away. And it is not possible to determine ifDynamic
something is larger thanDynamic
something else, these are not numeric values. There is more about this in the documentation, if I recall correctly there is a paragraph specifically about where to placeDynamic
. $\endgroup$