


Multiple function syntaxesĪ zero-argument function can be declared without parentheses: function fooĪ zero-result function can have no result array: function fooĪ one-result function can have no result array brackets: function result = foo Newer languages like C, Java, Python, Ruby, etc. This is reminiscent of old languages like Pascal and Visual Basic, where the value to return is assigned to the functionâs name. Setting function values = function(c, d)Ī function returns values by assigning output variables, instead of returning an expressionâs value. This could also suggest that the MATLAB language isnât designed properly with a recursive grammar. This might be similar to the distinction between lvalues and rvalues in C and C++. The matrix indexing/slicing syntax canât be used everywhere sometimes you need to introduce an intermediate variable. % Error: Unbalanced or unexpected parenthesis or bracket. % Error: ()-indexing must appear last in an index expression. But this use of the keyword end is confined to subscripts and cannot be used as a standalone value. Indexing a vector/matrix relative to the end (without using a length function) is convenient. C/C++ will exhibit undefined behavior (may work correctly, may corrupt data or crash). JavaScript also has this same misfeature. This makes it easy to mask mistakes in index calculations. Setting an element beyond the bounds of a vector/matrix will silently extend it. But this is conceptually impure, and other languages like Python and JavaScript will give you a properly nested array if you tried to use this syntax. This can be used as an idiom for appending or prepending one or more elements to a matrix. Syntactically nesting a matrix into another one yields a new matrix representing their concatenation. Other linear algebra systems like NumPy for Python donât suffer from this problem, and can work with 0-dimensional, 1D, 2D, 3D, etc. Also, for many applications that only need 1-dimensional arrays, there is a needless distinction between row vectors and column vectors. The extra degenerate dimensions are impure, and can lead to silent mistakes such as unintentionally extending along a dimension. Scalar numbers are matrices, and vectors are matrices in other words, every numerical object has at least 2 dimensions. (This behavior is the same in C, C++, JavaScript, Python but disallowed in Java, C#.)Īn important difference between logical and numeric types shows up when we take a vector subscript of an array/ matrix: array = -2 : +2 ĭisp(array(sub0)) % Equals ĭisp(array(sub1)) % Equals ĭisp(array(sub3)) % Runtime error Minimum 2 dimensions x = 8 However, the logical values false and true behave exactly as the numeric values 0 and 1 (respectively) in most computations: disp(true + true) % Prints 2 The logical type represents a Boolean value, which is separate from the numeric type. But having used many other programming languages in my career, the pain points of MATLAB show up clearly. Its design dates back from the 1980s and has evolved over the decades.

MATLAB is a proprietary programming language targeted toward linear algebra and rapid development.
