MATLAB derives its name from matrix laboratory and, as the name implies, is well suited for mathematics, science and engineering applications where matrices are used extensively. The high-level matrix language is supported by a large library of mathematical functions and an impressive set of graphical facilities.
The principal data type in MATLAB is an NxN matrix of complex numbers (using imaginary i). There are also three special cases consisting of 1xN row vectors, Nx1 column vectors and 1x1 scalars. A number is a scalar 1x1 matrix which can be concatenated using [] and ; to form larger matrices. Thus:-
[ 1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15 ]represents:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15In general, matrices of arbitrary size may be concatenated to form larger matrices. So:-
[ A B; C D ]is a concatenation of four matrices.
The basic operators are matrix operators and as such A * B indicates matrix multiplication requiring that A is LxM and B is MxN. Element-wise operators are denoted by a preceding dot. So A .* B denotes element-wise multiplication and requires that both A and B be MxN.
This use of matrices can have some interesting consequences for several aspects of programming using MATLAB: