I am trying to create a user interface for a demo project that uses matrix as an input. I provide user with a default matrix (as an example) for a start, but user can edit it or add extra row to it and then they could run the calculation on the input matrix by pressing Run button. I am getting the following error (shown in the figure below) whenever I open my document anew, but this error does not come when I run my cell once or twice.
When the cell is run once or twice it should work like this
Here is my code:
mat = ( {
{21, 72, 3.0044},
{0, 62.5, 3.5091},
{1, 200, 3.6835}
} );
Column[{
Dynamic[Table[
With[{xi = i, yj = j},
InputField[Dynamic[mat[[xi, yj]]], ImageSize -> 100]],
{i, Dimensions[mat][[1]]}, {j, 3}] // TableForm],
Row[{Button["ADD ROW (+)", Dynamic[mat = Append[mat, {0, 0, 0}]],
ImageSize -> 100],
Button["DEL. ROW (-)",
If[Dimensions[mat][[1]] > 1, mat = Delete[mat, -1]],
ImageSize -> 100]
}], y = "Press Run";
Button["Run", y = 2*mat // TableForm, ImageSize -> 200],
Dynamic@y
}]
Note: In reality, operation on matrix is more complicated function than multiplying it twice (y = 2*mat). It is shown here for simplicity.
It would be helpful if one could provide solution to solve this problem concerning: updating or editing a matrix dynamically and then performing some operation on it after pressing 'Run' button.
Thank you in advance.
Manipulate
expression? $\endgroup$