1

I can input a single row matrix by keyboard. as

x = {};
n = 3;
For[k = 1, k ≤ n, k++,
    br = Input[Row[{"Enter the ", k, " element"}]];
    AppendTo[x, br];
]

This will get a single row matrix like x={ 2, 3 , 6}. But If I want to get input as x = {{2,3,4},{4,5,6},{0,1,0}} by keyboard then what can I do?

  • Wrap another For loop around the outside of your For loop. The new loop counts rows. Make small changes to your code to then use this. – Bill Apr 03 '15 at 15:53

1 Answers1

1

better than the For loop:

 x = Table[ 
      Input[Row[{ "enter component:"  , i , j}] ], {i, 3}, {j, 3}]

and better still try this:

 Table[ ToExpression@StringSplit[
         InputString[
             Row[{"enter row", i , 
                  " ( three numbers space separated)" }]]], {i, 3}]
agentp
  • 6,849
  • 2
  • 19
  • 37