How to efficiently input matrices in Mathematica (compared to what MATLAB offers)

Quick-n-dirty. I dispense with open/close bracket, trivial to put in if it matters:

fn = ToExpression/@ImportString[StringReplace[#, ";" -> "\n"], "Table"] &;

mymat = "2 4;  3 4 5 ; 5 6" // fn
mymat2 = "a b;2 c; d 5" // fn

{{2, 4}, {3, 4, 5}, {5, 6}}

{{a, b}, {2, c}, {d, 5}}


You can make use of the build-in palettes e.g. the Basic Math Assistant. The major advantages are

  • MatrixForm-esque look for input
  • Tab can be used to fill the matrix from top left to bottom right.
  • 2D-Navigation using arrow keys is also possible.
  • Hotkeys for adding rows and columns

gif


m = Function[expr, Block[{Times = List, CompoundExpression = List}, expr], HoldAll];
m[b a; c d e]
(*{{b, a}, {c, d, e}}*)

Do notice this representation has conspicuous limitation e.g. it can not be used to represent {{a b}, {c, d e}}. It doesn't cause trouble in MATLAB because MATLAB doesn't have implicit time sign.

Also, it can't represent {i = 1; i + 1}. MATLAB suffers this problem, too.